예제 #1
0
 public SHPExporter(PgM.PgTableBaseM pgTable, FileInfo fileInfo, NpgsqlConnectionStringBuilder connect)
 {
     _connect    = connect;
     _pgTable    = pgTable;
     _fileInfo   = fileInfo;
     progressKey = "SHPExporterProgress" + DateTime.Now.Ticks.ToString();
 }
예제 #2
0
        private void SaveFile(string pathFile, int idFile, PgM.PgTableBaseM table)
        {
            FileStream   FS;
            BinaryWriter BW;

            FS = new FileStream(pathFile, FileMode.OpenOrCreate, FileAccess.Write);
            BW = new BinaryWriter(FS);
            var Param = new IParams[]
            {
                new Params(":id_file", idFile, DbType.Int32)
            };

            using (SqlWork sqlCmd = new SqlWork((table.Source as PgVM.PgDataRepositoryVM).Connect))
            {
                sqlCmd.sql = string.Format(@"SELECT ""{2}"" FROM ""{0}"".""{1}"" WHERE id = :id_file;",
                                           table.SchemeName,
                                           table.FileInfo.TableName,
                                           table.FileInfo.FieldFile);

                sqlCmd.ExecuteReader(Param);

                if (sqlCmd.CanRead())
                {
                    BW.Write(sqlCmd.GetBytes(0));
                }
            }
            BW.Close();
            FS.Close();
        }
예제 #3
0
        /// <summary>
        /// Используется для работы с историей
        /// </summary>
        /// <param name="table">Таблица для которой загружается история</param>
        /// <param name="idObject">Идентификатор объекта для которой загружается история</param>
        /// <param name="loadFromHistory">Использовать для загрузки атрибутов таблицу истории</param>
        /// <param name="idHistoryTable">Идентификатор таблицы истории из которой загружаются атрибуты</param>
        /// <param name="idHistoryObject">Идентификатор объекта в таблице истории</param>
        /// <param name="isReadOnly">Открываются ли атрибуты только для чтения</param>
        /// <param name="IsDebug">Запускается ли работа с атрибутами в режиме отладки</param>
        public PgAttributesListVM(PgM.PgTableBaseM table, object idObject, bool loadFromHistory, int?idHistoryTable = null, int?idHistoryObject = null, bool isReadOnly = false, bool IsDebug = false, bool loadStyle = true)
        {
            LoadStyle = loadStyle;
            if (loadFromHistory)
            {
                LoadFromHistory = loadFromHistory;
                IdHistoryTable  = (int)idHistoryTable;
                IdHistoryObject = (int)idHistoryObject;
            }
            _isDebug = IsDebug;
            _connect = ((PgVM.PgDataRepositoryVM)table.Source).Connect;
            if (isReadOnly || table.IsReadOnly || !table.CanWrite)
            {
                _isReadOnly = true;
            }
            _table = table;
            if (!String.IsNullOrEmpty(_table.GeomField))
            {
                _geomAttribute = new PgAtM.PgAttributeM(this, (PgM.PgFieldM)_table.Fields.First(p => p.Name == _table.GeomField));
            }

            _pkAttribute = new PgAtM.PgAttributeM(this, (PgM.PgFieldM)_table.PrimaryKeyField, idObject);
            if (idObject == null)
            {
                _isNew = true;
            }

            _attributes = new ObservableCollection <PgAtM.PgAttributeM>();
        }
예제 #4
0
        override public void Init(FileInfo inputFile, PgM.PgTableBaseM pgTable)
        {
            _inputFile = inputFile;
            _pgTable   = pgTable;
            if (pgTable != null)
            {
                _connect = (pgTable.Source as PgVM.PgDataRepositoryVM).Connect;
            }

            _shpWork              = new SHPWork(inputFile);
            _rowsCount            = _shpWork.GetFeatureCount();
            WorkerReportsProgress = true;
            try
            {
                _srid = _shpWork.getSRID();
            }
            catch (Exception ex)
            {
                SelectProjectionV  frmProj     = new SelectProjectionV();
                SelectProjectionVM datacontext = new SelectProjectionVM(frmProj);
                frmProj.DataContext = datacontext;
                if (frmProj.ShowDialog() == true)
                {
                    var proj = datacontext.SelectedProj;
                    if (proj != null)
                    {
                        _srid = proj.Srid;
                    }
                }
                else
                {
                    throw new Exception("Не указана проекция слоя!");
                }
            }
        }
예제 #5
0
        /// <summary>
        /// Функция генерации sql запроса
        /// </summary>
        /// <param name="table">Таблица с полями</param>
        /// <param name="whereId">Where запрос</param>
        /// <param name="isStyle">Таблица со стилем</param>
        /// <returns>Сгенерированая строка SQL запроса</returns>
        private string GetSQLQuery(PgM.PgTableBaseM table, string whereId)
        {
            var listColumns = new List <string>();

            for (int i = table.Fields.Count - 1; i >= 0; i--)
            {
                var item = table.Fields[i] as PgM.PgFieldM;

                string select = "";
                if (item.Type == AbsM.EFieldType.Geometry)
                {
                    select = String.Format(@"st_ASTEXT(st_TRANSFORM(""{0}"", :srid)) AS ""{0}""", item.Name);
                }
                else
                {
                    select = String.Format(@"""{0}""", item.Name);
                }

                listColumns.Add(select);
            }

            return(string.Format(@"
                                SELECT 
                                    {0} 
                                FROM 
                                    {1}.{2} 
                                WHERE 
                                    {3}",
                                 string.Join(", \n\t", listColumns.ToArray()),
                                 table.SchemeName,
                                 table.Name,
                                 whereId));
        }
예제 #6
0
        public override ValidationResult Validate(object value, CultureInfo cultureInfo)
        {
            BindingGroup bindingGroup = (BindingGroup)value;

            if (bindingGroup.Items.Count > 0)
            {
                object           obj    = bindingGroup.Items[0];
                PgM.PgTableBaseM tableM = obj as PgM.PgTableBaseM;

                String         schemeName = (String)bindingGroup.GetValue(tableM, "SchemeName");
                String         baseName   = (String)bindingGroup.GetValue(tableM, "Name");
                String         systemName = (String)bindingGroup.GetValue(tableM, "Text");
                AbsM.EGeomType geomType   = (AbsM.EGeomType)((EnumWrapper)(bindingGroup.GetValue(tableM, "GeomType"))).Value;

                if (String.IsNullOrEmpty(schemeName))
                {
                    return(new ValidationResult(false, "Схема не должна быть пустой"));
                }
                if (String.IsNullOrEmpty(baseName))
                {
                    return(new ValidationResult(false, "Название таблицы в базе не должно быть пустым"));
                }
                if (String.IsNullOrEmpty(systemName))
                {
                    return(new ValidationResult(false, "Название таблицы в системе не должно быть пустым"));
                }
                if (tableM.IsLayer && geomType == AbsM.EGeomType.None)
                {
                    return(new ValidationResult(false, "Слой карты должен иметь тип геометрии"));
                }
            }

            return(ValidationResult.ValidResult);
        }
예제 #7
0
        /// <summary>
        /// Применить фильтр на карте
        /// </summary>
        public void ApplyOnMap(object parameter = null)
        {
            AxmvMapLib.AxMapLIb axMapLib = Program.mainFrm1.axMapLIb1;
            Pg_M.PgTableBaseM   pgTable  = _source.Table as Pg_M.PgTableBaseM;

            mvLayer layer = axMapLib.getLayer(pgTable.NameMap);

            if (layer != null)
            {
                List <IParams> listParams = new List <IParams>();
                String         query      = GetWhere(DynamicFilter, listParams);
                // todo: (Dias) На текущий момент axMapLib в строке фильтра не использует параметры.
                // Поэтому приходится парсить параметры. Нужно чтобы карта поддерживала параметры в фильтрах
                foreach (IParams param in listParams)
                {
                    if (param.type == DbType.Date ||
                        param.type == DbType.DateTime ||
                        param.type == DbType.String)
                    {
                        query = query.Replace(param.paramName, String.Format("'{0}'", param.value));
                    }
                    else
                    {
                        query = query.Replace(param.paramName, String.Format("{0}", param.value));
                    }
                }
                layer.Filter = query;
            }
        }
예제 #8
0
        public object Clone()
        {
            PgTableBaseM pgTable = this.MemberwiseClone() as PgTableBaseM;

            PgTableBaseM.UpdateIsNewTable(pgTable, true);

            int postfixIndex = 0;

            pgTable.Name = "";
            do
            {
                String newNameInBase = Name + "_copy" + ((postfixIndex == 0) ? "" : String.Format("_{0}", postfixIndex));
                String newText       = Text + " копия" + ((postfixIndex == 0) ? "" : String.Format(" {0}", postfixIndex));
                postfixIndex++;
                using (SqlWork sqlWork = new SqlWork((Source as PgVM.PgDataRepositoryVM).Connect))
                {
                    sqlWork.sql = String.Format("SELECT EXISTS(SELECT * FROM sys_scheme.table_info WHERE scheme_name = '{0}' AND name_db = '{1}')",
                                                SchemeName, newNameInBase);
                    if (!(Boolean)(sqlWork.ExecuteScalar()))
                    {
                        pgTable.Name = newNameInBase;
                        pgTable.Text = newText;
                    }
                }
            }while (String.IsNullOrEmpty(pgTable.Name));
            return(pgTable);
        }
예제 #9
0
        override public void Init(FileInfo inputFile, PgM.PgTableBaseM pgTable)
        {
            _inputFile = inputFile;
            _pgTable   = pgTable;
            _pgConnect = (pgTable.Source as PgVM.PgDataRepositoryVM).Connect;

            var excelAppl = new Excel.Application()
            {
                Visible = false
            };
            var workbook = excelAppl.Workbooks.Open(_inputFile.FullName);

            excelUC.listCB.Items.Clear();
            Excel.Worksheet sheet = null;
            foreach (Excel.Worksheet worksheet in workbook.Sheets)
            {
                excelUC.listCB.Items.Add(worksheet.Name);
                if (sheet == null)
                {
                    sheet = worksheet;
                }
            }
            GC.Collect(2, GCCollectionMode.Forced);             //не знаю зачем это
            GC.WaitForPendingFinalizers();
            excelUC.listCB.SelectedIndex = 0;
            var    workrange = sheet.UsedRange;
            String rng       = GetUsedNotEmptyRange(sheet);

            if (rng != null)
            {
                String upLeft      = rng.Split(':')[0];
                String bottomRight = rng.Split(':')[1];
                excelUC.diapBeg.Text = upLeft;
                excelUC.diapEnd.Text = bottomRight;
                String          sheetString = sheet.Name;
                String          rangeString = rng;
                Excel.Worksheet workSheet   = (Excel.Worksheet)(workbook.Sheets.Item[sheetString]);
                Excel.Range     workRange   = workSheet.get_Range(rangeString);
                // Где на странице Excel находятся данные
                int lastRow     = workRange.Row + workRange.Rows.Count - 1;
                int firstRow    = workRange.Row;
                int lastColumn  = workRange.Column + workRange.Columns.Count - 1;
                int firstColumn = workRange.Column;
                // Получаются данные из excel в виде массива объектов
                var excValues = (object[, ])(workRange.Value);
                // Сколько строк и сколько столбцов
                _rowsCount = excValues.GetLength(0) - 1;                //первая строка заголовки
            }
            else
            {
                excelUC.diapBeg.Text = excelUC.diapEnd.Text = "Нет данных";
                _rowsCount           = 0;
            }
            GC.Collect(2, GCCollectionMode.Forced);            //не знаю зачем это
            GC.WaitForPendingFinalizers();
            workbook.Close();
            excelAppl.Quit();
            WorkerReportsProgress = true;
        }
예제 #10
0
        /// <summary>
        /// Сохранение активного фильтра
        /// </summary>
        public void Save(object parameter = null)
        {
            FilterSaveFrm frm = new FilterSaveFrm();

            frm.Text = "Фильтр";
            if (frm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                int idSource = 0;
                int idTable  = 0;

                Npgsql.NpgsqlConnectionStringBuilder connect = (_source.Table.Source as PgDataRepositoryVM).Connect;
                String            sourceName = String.Format("{0}@{1}", connect.Database, connect.Host);
                String            sourceType = _source.Table.Source.Type.ToString();
                Pg_M.PgTableBaseM pgTable    = _source.Table as Pg_M.PgTableBaseM;
                String            tableName  = String.Format("\"{0}\".\"{1}\"", pgTable.SchemeName, pgTable.Name);

                bool sourceExists = (from Source src
                                     in Program.SettingsDB.Sources
                                     where src.SourceName == sourceName && src.SourceType == sourceType
                                     select src).Count() > 0;
                if (!sourceExists)
                {
                    Program.SettingsDB.Sources.AddObject(new Source()
                    {
                        SourceName = sourceName, SourceType = sourceType
                    });
                }
                idSource = Convert.ToInt32((from Source src
                                            in Program.SettingsDB.Sources
                                            where src.SourceName == sourceName && src.SourceType == sourceType
                                            select src.Id).FirstOrDefault());
                bool tableExists = (from Table tbl
                                    in Program.SettingsDB.Tables
                                    where tbl.SourceId == idSource && tbl.TableName == tableName
                                    select tbl).Count() > 0;
                if (!tableExists)
                {
                    Program.SettingsDB.Tables.AddObject(new Table()
                    {
                        TableName = tableName, SourceId = idSource
                    });
                }
                idTable = Convert.ToInt32((from Table tbl
                                           in Program.SettingsDB.Tables
                                           where tbl.TableName == tableName && tbl.SourceId == idSource
                                           select tbl.Id).FirstOrDefault());

                FilterRelationModel filterRM = GetFilterModel(_dynamicFilter);
                Program.SettingsDB.Filters.AddObject(new Filter()
                {
                    FilterName = frm.textBox1.Text,
                    WhereText  = SqlJsonParser.ToJson(filterRM),
                    IdTable    = idTable
                });
                Program.SettingsDB.SaveChanges();
                ReloadFiltersFromSqLite();
            }
        }
예제 #11
0
        public PgIndexVM(PgM.PgTableBaseM table)
        {
            _table            = table;
            _source           = table.Source as PgVM.PgDataRepositoryVM;
            _indexedFields    = new ObservableCollection <AbsM.IFieldM>();
            _notIndexedFields = new ObservableCollection <AbsM.IFieldM>();

            LoadIndexInfo();
        }
예제 #12
0
 /// <summary>
 /// Удаление таблицы из группы
 /// </summary>
 public void ExcludeFromGroup(object parameter = null)
 {
     PgM.PgTableBaseM pgTable = parameter as PgM.PgTableBaseM;
     if (!_doesntContainList.Contains(pgTable))
     {
         _doesntContainList.Add(pgTable);
         _containsList.Remove(pgTable);
     }
 }
예제 #13
0
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            PgM.PgTableBaseM table = (PgM.PgTableBaseM)value;
            if (table == null)
            {
                return(Visibility.Collapsed);
            }
            AbsM.ETableType tabletype = table.Type;
            String          par       = parameter.ToString();

            switch (par)
            {
            case "Структура":
            case "Свойства":
            {
                return(Visibility.Visible);
            }

            case "Группы":
            case "Подписи":
            case "Стили":
            {
                if (tabletype == AbsM.ETableType.MapLayer || tabletype == AbsM.ETableType.View)
                {
                    return(Visibility.Visible);
                }
                else
                {
                    return(Visibility.Collapsed);
                }
            }

            case "Права":
            {
                PgM.PgUserM user = (table.Source as PgVM.PgDataRepositoryVM).CurrentUser;
                if (user == null || user.Type == PgM.UserType.User)
                {
                    return(Visibility.Collapsed);
                }
                else
                {
                    return(Visibility.Visible);
                }
            }

            case "Индекс":
            {
                return(Visibility.Visible);
            }

            default:
            {
                return(Visibility.Collapsed);
            }
            }
        }
예제 #14
0
 public PgAttributesStyleVM(PgAtVM.PgAttributesVM attributeVM)
 {
     _attributeVM = attributeVM;
     _isDebug     = attributeVM.IsDebug;
     _connect     = attributeVM.Connect;
     _isReadOnly  = attributeVM.IsReadOnly;
     _table       = attributeVM.Table;
     _pkAttribute = attributeVM.AttributesListVM.PkAttribute;
     _style       = new PgM.PgStyleObjectM(_table, _pkAttribute.Value);
 }
예제 #15
0
 public PgLayerGroupsVM(PgM.PgTableBaseM pgtable)
 {
     _table  = pgtable;
     _source = pgtable.Source as PgVM.PgDataRepositoryVM;
     _source.GroupsCollectionChanged += Source_GroupsCollectionChanged;
     foreach (AbsM.GroupM groupM in _source.Groups)
     {
         groupM.Tables.CollectionChanged += Tables_CollectionChanged;
     }
     ReloadGroups();
 }
예제 #16
0
        /// <summary>
        /// Загрузка связанных таблиц
        /// </summary>
        private void LoadRelatedTables(object idObject)
        {
            if (idObject != null && (_table.Type == AbsM.ETableType.Data || _table.Type == AbsM.ETableType.MapLayer))
            {
                RelatedTables.Clear();
                using (SqlWork sqlWork = new SqlWork(Connect))
                {
                    // Запрос для получения идентификаторов связанных таблиц
                    sqlWork.sql = String.Format(@"SELECT tfi.id_table, tfi.name_db, tfi.ref_field
                                    FROM sys_scheme.table_field_info tfi 
                                    INNER JOIN sys_scheme.table_info ti ON tfi.id_table = ti.id
                                    INNER JOIN sys_scheme.table_type_table ttt ON ttt.id = ti.type
                                    WHERE tfi.ref_table = {0} AND (ttt.id = 1 OR ttt.id = 4)", _table.Id);
                    sqlWork.ExecuteReader();
                    while (sqlWork.CanRead())
                    {
                        int    idTable    = sqlWork.GetInt32("id_table");
                        string colName    = sqlWork.GetString("name_db");
                        int    refFieldId = sqlWork.GetInt32("ref_field");

                        PgM.PgFieldM field = _table.Fields.FirstOrDefault(f => f.Id == refFieldId) as PgM.PgFieldM;

                        if (field != null && field.Table != null && field.Table.Id is int &&
                            classesOfMetods.getRefTableRight(_table.Id, (int)field.Table.Id))
                        {
                            PgAtM.PgAttributeM attr        = _attributesListVM.Attributes.FirstOrDefault(a => a.Field == field);
                            String             filterValue = null;
                            if (attr.Value != null)
                            {
                                filterValue = attr.Value.ToString();
                            }

                            PgM.PgTableBaseM pgTable = _table.Source.Tables.FirstOrDefault(p => (int)p.Id == idTable) as PgM.PgTableBaseM;
                            if (pgTable != null)
                            {
                                FilterRelationModel filterRM = new FilterRelationModel()
                                {
                                    Type    = TypeRelation.ELEMENT,
                                    Element = new FilterElementModel()
                                    {
                                        Column = colName,
                                        Type   = TypeOperation.Equal,
                                        Value  = filterValue
                                    }
                                };
                                RelatedTables.Add(new PgTV.PgTableViewVM(pgTable, filterRM));
                            }
                        }
                    }
                    sqlWork.Close();
                }
            }
            OnPropertyChanged("HasRelatedTables");
        }
예제 #17
0
        public PgFieldM(AbsM.ITableBaseM table, int id)
        {
            _id = id;
            var pgTable = table as PgM.PgTableBaseM;

            if (pgTable == null)
            {
                throw new ArgumentNullException("Нет ссылки на таблицу");
            }
            _table   = pgTable;
            _idTable = _table.Id;
        }
예제 #18
0
        override public void Init(FileInfo inputFile, PgM.PgTableBaseM pgTable)
        {
            _inputFile = inputFile;
            _pgTable   = pgTable;
            _pgConnect = (pgTable.Source as PgVM.PgDataRepositoryVM).Connect;

            var reader = (new OleDbCommand(string.Format("SELECT count(*) FROM [{0}#dbf]", Name), Connection)).ExecuteReader();

            if (!reader.Read() || !int.TryParse(reader[0].ToString(), out _rowsCount))
            {
                _rowsCount = 0;
            }
            WorkerReportsProgress = true;
        }
예제 #19
0
        public PgAttributesVM(AbsM.ITableBaseM table, object idObject, bool isReadOnly = false, bool isDebug = false, String wkt = null)
        {
            var pgTable = table as PgM.PgTableBaseM;

            if (pgTable == null)
            {
                throw new ArgumentNullException("Нет ссылки на таблицу");
            }
            else if (pgTable.PrimaryKeyField == null)
            {
                throw new ArgumentNullException("В таблице нет первичного ключа");
            }

            _isDebug = isDebug;
            _connect = ((PgVM.PgDataRepositoryVM)pgTable.Source).Connect;
            _table   = pgTable;
            _source  = pgTable.Source as PgVM.PgDataRepositoryVM;

            // Проверка прав на объект с атрибутами
            if (isReadOnly || pgTable.IsReadOnly || !pgTable.CanWrite)
            {
                _isReadOnly = true;
            }

            _attributesListVM = new PgAtVM.PgAttributesListVM(this, idObject);
            if (_table.FileInfo != null)
            {
                _filesVM = new PgAtVM.PgAttributeFilesVM(this);
            }
            if (_table.IsMapStyle && idObject != null)
            {
                _styleVM = new PgAttributesStyleVM(this);
            }
            if (_table.Type == AbsM.ETableType.MapLayer || _table.Type == AbsM.ETableType.View)
            {
                //_pgGeometryVM = new PgAttributesGeomVM(this, wkt);
                _pgGeometryVM = new PgAttributesGeomVM(_table.Id, wkt, false, (int?)_attributesListVM.PkAttribute.Value, (_table.Source as PgVM.PgDataRepositoryVM).Connect);
            }
            Title = String.Format("Объект: [id: {0}]; Таблица: \"{1}\"; Источник: \"{3}@{4}:{5} ({6})\"; Тип: \"{2}\"",
                                  idObject ?? "null",
                                  _table.Text,
                                  _table.Source.Type,
                                  _source.Connect.Database,
                                  _source.Connect.Host,
                                  _source.Connect.Port,
                                  _source.CurrentUser.NameFull);
        }
예제 #20
0
        /// <summary>
        /// ViewModel для окна списка объектов
        /// </summary>
        /// <param name="table">Таблица с объектами</param>
        /// <param name="filter">Фильтр который нужно применить для данного окна</param>
        /// <param name="id">Перейти к нужному объекту</param>
        /// <param name="toSelected"> Открыть окно для выбора объекта</param>
        /// <param name="isDebug"> Debug режим </param>
        public PgTableViewVM(AbsM.ITableBaseM table, FilterRelationModel filter = null, object id = null, bool toSelected = false, bool isDebug = false)
        {
            var pgTable = table as PgM.PgTableBaseM;

            if (pgTable == null)
            {
                throw new ArgumentNullException("table");
            }
            _table      = pgTable;
            _isReadOnly = _table.IsReadOnly;
            _source     = pgTable.Source as PgVM.PgDataRepositoryVM;
            _connect    = Source.Connect;
            _sysScheme  = "sys_scheme";
            _isDebug    = isDebug;
            Title       = String.Format("Таблица: \"{0}\"; Источник: \"{2}@{3}:{4} ({5})\"; Тип: \"{1}\"",
                                        pgTable.Text,
                                        _source.Type,
                                        _source.Connect.Database,
                                        _source.Connect.Host,
                                        _source.Connect.Port,
                                        _source.CurrentUser.NameFull);

            _columns  = new ObservableCollection <HeaderValue>();
            sqlSelect = GetSQL();

            _filterVM = new PgTableView.PgTableViewFilterVM(this, filter);

            if (id != null)
            {
                int?page = GetPageInTable(id);
                if (page != null)
                {
                    PageCurrent = page;
                }
            }
            GetColumns();
            Reload();
            if (id != null)
            {
                CurrentRowView = GetRow(id);
            }
            _toSelected = toSelected;

            _source.EventUpdateAttribute += _source_EventUpdateAttribute;
            this.PropertyChanged         += PgTableViewVM_PropertyChanged;
        }
예제 #21
0
        /// <summary>
        /// Загружает из базы SQLite названия и идентификаторы всех фильтров, относящихся к таблице _source.Table
        /// </summary>
        private void ReloadFiltersFromSqLite()
        {
            IdNameFilter.Clear();
            Npgsql.NpgsqlConnectionStringBuilder connect = (_source.Table.Source as PgDataRepositoryVM).Connect;
            Pg_M.PgTableBaseM pgTable    = _source.Table as Pg_M.PgTableBaseM;
            String            sourceName = String.Format("{0}@{1}", connect.Database, connect.Host);
            String            sourceType = pgTable.Source.Type.ToString();
            String            tableName  = String.Format("\"{0}\".\"{1}\"", pgTable.SchemeName, pgTable.Name);
            var filters = from Filter f
                          in Program.SettingsDB.Filters
                          where f.Table.TableName == tableName && f.Table.Source.SourceName == sourceName && f.Table.Source.SourceType == sourceType
                          select f;

            foreach (var filter in filters)
            {
                IdNameFilter.Add(new NameValue(filter.Id, filter.FilterName));
            }
        }
예제 #22
0
        /// <summary>
        /// Работы с атрибутами объекта
        /// </summary>
        /// <param name="table">Ссылка на таблицу</param>
        /// <param name="idObject">Идентификатор объекта с атрибутами.
        /// Если он null создается новый</param>
        /// <exception cref="ArgumentNullException"/>
        public PgAttributesListVM(PgAtVM.PgAttributesVM attributeVM, object idObject, bool loadStyle = true)
        {
            LoadStyle    = loadStyle;
            _attributeVM = attributeVM;

            _isDebug    = attributeVM.IsDebug;
            _connect    = attributeVM.Connect;
            _isReadOnly = attributeVM.IsReadOnly;
            _table      = attributeVM.Table;
            if (!String.IsNullOrEmpty(_table.GeomField))
            {
                _geomAttribute = new PgAtM.PgAttributeM(this, (PgM.PgFieldM)_table.Fields.First(p => p.Name == _table.GeomField));
            }

            _pkAttribute = new PgAtM.PgAttributeM(this, (PgM.PgFieldM)_table.PrimaryKeyField, idObject);
            if (idObject == null)
            {
                _isNew = true;
            }

            _attributes = new ObservableCollection <PgAtM.PgAttributeM>();
        }
예제 #23
0
        public ImportWindow(FileInfo inputFile, PgM.PgTableBaseM pgTable)
        {
            InitializeComponent();
            _pgTable = pgTable;
            _connect = (pgTable.Source as PgVM.PgDataRepositoryVM).Connect;

            colsTim = new DispatcherTimer()
            {
                Interval = new TimeSpan(0, 0, 0, 0, 200), IsEnabled = false
            };
            colsTim.Tick    += new EventHandler(loadCols);
            inputFileTb.Text = inputFile.FullName;
            switch (inputFile.Extension.ToLower())
            {
            case ".dbf":
                importer = new Importers.DBFImporter();
                break;

            case ".xls":
            case ".xlsx":
                importer = new Importers.ExcelImporter();
                break;

            case ".shp":
            case ".tab":
            case ".bna":
            case ".csv":
            case ".geojson":
            case ".gml":
            case ".gmt":
            case ".itf":
            case ".sqlite":
                importer = new Importers.SHPImporter();
                break;

            default:
                importer = null;
                break;
            }
            hideError();
            hideSuccess();
            if (importer == null)
            {
                showError("Выбранный тип файла загрузчиком не поддерживается");
                return;
            }
            importer.ProgressChanged    += new System.ComponentModel.ProgressChangedEventHandler(importer_ProgressChanged);
            importer.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(importer_RunWorkerCompleted);
            progressKey = "importProgress" + DateTime.Now.Ticks.ToString();
            settingsSP.Children.Clear();
            try
            {
                cti.ThreadProgress.ShowWait();
                if (importer.SettingsPanel != null)
                {
                    settingsSP.Children.Add(importer.SettingsPanel);
                }
                importer.Init(inputFile, _pgTable);
            }
            catch (Exception ex)
            {
                showError(ex.Message);
                return;
            }
            finally
            {
                cti.ThreadProgress.Close();
            }
            if (_pgTable != null)
            {
                dbTableCB.Text = _pgTable.Name;
            }
        }
예제 #24
0
 public TXTExporter(PgM.PgTableBaseM table, NpgsqlConnectionStringBuilder connect, FileInfo fileInfo)
 {
     _connect  = connect;
     _pgTable  = table;
     _fileInfo = fileInfo;
 }
예제 #25
0
 abstract public void Init(FileInfo inputFile, PgM.PgTableBaseM pgTable);
예제 #26
0
 public PgStyleLableM(PgTableBaseM table, PgStyleSetsM set)
 {
     _isNewTable = true;
     _table      = table;
     _set        = set;
 }
예제 #27
0
 public PgStyleLableM(int id, PgTableBaseM table, PgStyleSetsM set)
 {
     _id    = id;
     _table = table;
     _set   = set;
 }