Exemplo n.º 1
0
        static public List <IGeoInfo> GetDataList(HMCon hmConn, List <DataRow> rowList, IMapLayer layer)
        {
            if (rowList.Count == 0)
            {
                return(new List <IGeoInfo>());
            }

            string linkCodeList = GetContentListString(rowList, layer.LinkColumn);

            if (layer is MapPointLayer)
            {
                return(GetPointList(hmConn, rowList, layer.ConvertTo <MapPointLayer>(), linkCodeList));
            }
            else if (layer is MapShapeLayer)
            {
                return(GetShapeList(hmConn, rowList, layer.ConvertTo <MapShapeLayer>(), linkCodeList));
            }
            else if (layer is MapLineLayer)
            {
                return(GetLineList(hmConn, rowList, layer.ConvertTo <MapLineLayer>(), linkCodeList));
            }
            else if (layer is MapEventLayer)
            {
                return(GetEventList(hmConn, rowList, layer.ConvertTo <MapEventLayer>(), linkCodeList));
            }

            return(null);
        }
Exemplo n.º 2
0
        public ucDrawBase CreateInstance(HMCon con, TUC_HMDevXManager.TUC_HMDevXManager hmDevMgr, WpfMapDrawBase map, IMapLayer info, int layerIndex)
        {
            if (info is MapPointLayer)
            {
                return(new ucDrawPoint(con, hmDevMgr, map, info.ConvertTo <MapPointLayer>(), layerIndex));
            }
            else if (info is MapShapeLayer)
            {
                return(new ucDrawShape(con, hmDevMgr, map, info.ConvertTo <MapShapeLayer>(), layerIndex));
            }
            else if (info is MapLineLayer)
            {
                return(new ucDrawLine(con, hmDevMgr, map, info.ConvertTo <MapLineLayer>(), layerIndex));
            }
            else if (info is MapEventLayer)
            {
                if (_eventDrawer == null)
                {
                    _eventDrawer = new ucDrawEvents(con, hmDevMgr, map, info.ConvertTo <MapEventLayer>(), layerIndex);
                    return(_eventDrawer);
                }
                else
                {
                    _eventDrawer.AddEventLayer(info.ConvertTo <MapEventLayer>(), layerIndex);
                    return(null);
                }
            }

            return(null);
        }
Exemplo n.º 3
0
        private void DeleteOldData()
        {
            for (int i = 0; i < gv.RowCount; i++)
            {
                var row = gv.GetDataRow(i);
                if (new string[] { ImportAction.Delete, ImportAction.Overwrite }.Contains($"{row["Action"]}"))
                {
                    if (_layer is MapEventLayer)
                    {
                        _hmCon.SQLExecutor.ExecuteNonQuery($"delete Geo_Event where LinkCode='{row[ColumnNames.Key]}' and EventTypeId={_layer.ConvertTo<MapEventLayer>().TypeId}", _hmCon.TRConnection);
                    }
                    else
                    {
                        string    sql       = $"select * from Geo_Link where LinkTableName='{_layer.LinkTable}' and Feature='{_layer.LayerName}' and LinkCode='{row[ColumnNames.Key]}'";
                        DataTable table     = _hmCon.SQLExecutor.ExecuteDataAdapter(sql, _hmCon.TRConnection);
                        int       oldLinkId = (int)table.Rows[0]["LinkId"];
                        int       oldId     = (int)table.Rows[0]["Id"];

                        _hmCon.SQLExecutor.ExecuteNonQuery($"delete Geo_Link where Id={oldId}", _hmCon.TRConnection);

                        if (_layer is MapShapeLayer)
                        {
                            _hmCon.SQLExecutor.ExecuteNonQuery($"delete Geo_Shape where ShapeId={oldLinkId}", _hmCon.TRConnection);
                        }
                        else if (_layer is MapLineLayer)
                        {
                            _hmCon.SQLExecutor.ExecuteNonQuery($"delete Geo_Polyline where PolylineId={oldLinkId}", _hmCon.TRConnection);
                        }
                        else if (_layer is MapPointLayer)
                        {
                            _hmCon.SQLExecutor.ExecuteNonQuery($"delete Geo_Point where Id={oldLinkId}", _hmCon.TRConnection);
                        }
                    }

                    row[ColumnNames.OldData] = string.Empty;
                    if ($"{row[ColumnNames.Action]}" == ImportAction.Delete)
                    {
                        row[ColumnNames.Action] = ImportAction.Ignore;
                    }
                }
            }
        }
Exemplo n.º 4
0
        static public PenBase CreateInstance(IMapLayer info)
        {
            if (info is MapPointLayer)
            {
                return(new PenPoint());
            }
            else if (info is MapShapeLayer)
            {
                return(new PenShape());
            }
            else if (info is MapLineLayer)
            {
                return(new PenLine());
            }
            else if (info is MapEventLayer)
            {
                return(new PenEvent(info.ConvertTo <MapEventLayer>()));
            }

            return(null);
        }
Exemplo n.º 5
0
        public void Init(HMCon con, TUC_HMDevXManager.TUC_HMDevXManager hmDevMgr, List <DataRow> rowList, IMapLayer layer)
        {
            _hmCon    = con;
            _hmDevMgr = hmDevMgr;
            _layer    = layer;
            _pop      = new frmPopup(_hmDevMgr);

            labelTableName.Text   = _layer.LinkTable;
            labelFieldName.Text   = layer.LinkColumn;
            labelFeatureName.Text = layer.LayerName;

            _table = new DataTable();
            _table.Columns.Add(new DataColumn(ColumnNames.Key));
            _table.PrimaryKey = new DataColumn[] { _table.Columns[ColumnNames.Key] };
            layer.Attributes.ToList().ForEach(attr => _table.Columns.Add(new DataColumn(attr.DisplayName)));
            _table.Columns.Add(new DataColumn(ColumnNames.OldData));
            _table.Columns.Add(new DataColumn(ColumnNames.NewData));
            _table.Columns.Add(new DataColumn(ColumnNames.Action));

            foreach (var srcRow in rowList)
            {
                var row = _table.NewRow();

                row[ColumnNames.Key] = srcRow[layer.LinkColumn];
                layer.Attributes.ToList().ForEach(attr => row[attr.DisplayName] = attr.LinkDictionary?[$"{srcRow[attr.LinkField]}"] ?? srcRow[attr.LinkField]);
                _table.Rows.Add(row);
            }

            try
            {
                if (rowList.Count > 0)
                {
                    string linkCodeList = MapData.GetContentListString(rowList, layer.LinkColumn);
                    string sql          = "";
                    if (layer is MapEventLayer)
                    {
                        sql = $"select * from Geo_Event where EventTypeId={layer.ConvertTo<MapEventLayer>().TypeId} and LinkCode in ({linkCodeList})";
                    }
                    else
                    {
                        sql = $"select * from Geo_Link where LinkTableName='{layer.LinkTable}' and Feature='{layer.LayerName}' and LinkCode in ({linkCodeList})";
                    }
                    var linkTable = _hmCon.SQLExecutor.ExecuteDataAdapter(sql, _hmCon.TRConnection);
                    _table.Select().ToList().ForEach(row => row[ColumnNames.OldData] = linkTable.Select($"LinkCode='{row[ColumnNames.Key]}'").Length > 0 ? strYes : string.Empty);
                    _table.Select().ToList().ForEach(row => row[ColumnNames.Action]  = ImportAction.Ignore);
                }
            }
            catch (Exception ex)
            {
                _pop.ShowPopup($"Error in loading: {ex.Message}");
            }

            gc.DataSource = _table;

            _luAllAction            = new RepositoryItemLookUpEdit();
            _luAllAction.DataSource = new string[] { ImportAction.Ignore, ImportAction.Add, ImportAction.Overwrite, ImportAction.Delete };
            gc.RepositoryItems.Add(_luAllAction);
            gv.Columns["Action"].ColumnEdit = _luAllAction;

            gv.Columns.ToList().ForEach(col => col.OptionsColumn.AllowEdit = col.FieldName == ColumnNames.Action);

            _luAction = new RepositoryItemLookUpEdit();
        }