Beispiel #1
0
        /// <summary>
        /// Выполнить генерализацию.
        /// </summary>
        /// <param name="scale">Масштаб составялемой карты.</param>
        /// <param name="inDbMap">Исходная карта.</param>
        /// <param name="outDbMap">Составляемая карта.</param>
        /// <param name="message">Сообщение ошибки.</param>
        /// <returns>Успешно ли прошел алгоритм генерализации.</returns>
        public bool Execute(long scale, DbMap inDbMap, out DbMap outDbMap, out string message)
        {
            message = string.Empty;

            // Вычисляем количество точек составляемой карты.
            int countPointsOfOutDbMap = 0;
            if (SettingGen.SelectionRule == SelectionRules.Topfer)
            {
                countPointsOfOutDbMap = SelectionFunctions.FunctionTopfer(inDbMap.Scale, scale, inDbMap.CloudPoints.Length);
            }

            // Выполняем кластеризацию.
            Point[] cloudPoints;
            bool isClustering = _clusteringAlgoritm.Execute(inDbMap.CloudPoints, countPointsOfOutDbMap, out cloudPoints, out message);

            // Обрабатываем результат кластеризации.
            if (isClustering)
            {
                outDbMap = new DbMap(inDbMap.Name, inDbMap.Width, inDbMap.Length, scale, inDbMap.Latitude,inDbMap.Longitude, cloudPoints);
                return true;
            }

            outDbMap = null;
            return false;
        }
Beispiel #2
0
        // MAPS

        public async Task <IMap> NewMapAsync(IGame game, IMap map)
        {
            var gridMap = (GridMap)map;
            var dbMap   = new DbMap()
            {
                RecordBy    = "notlinktoausercontextyet",
                RecordDate  = DateTimeOffset.Now,
                Name        = map.Name,
                Description = map.Description,
                LocationX   = gridMap.Location.X,
                LocationY   = gridMap.Location.Y,
                LocationZ   = gridMap.Location.Z,
                Exits       = gridMap.Exits.Distinct().Select(exit => new DbMapExit()
                {
                    Direction = (byte)exit
                }).ToList()
            };

            using (var context = new GameDbContext())
            {
                var savedMap = await context.AddAsync(dbMap);

                await context.SaveChangesAsync();

                return(savedMap.Entity.ToMap());
            }
        }
Beispiel #3
0
        public static bool UpdateObject <T> (this DbConnection gdb, T obj)
        {
            MySqlConnection db = (MySqlConnection)gdb;

            using (MySqlCommand cmd = db.CreateCommand()) {
                DbMap         map = GetMap(obj.GetType());
                StringBuilder sql = new StringBuilder("UPDATE `");
                sql.Append(map.Table).Append("` SET ");

                foreach (var f in map)
                {
                    if (f.Key == map.IdentityField)
                    {
                        continue;
                    }
                    string fp = "@_" + f.Key;
                    sql.Append(f.Key).Append('=').Append(fp).Append(',');
                    object val = f.Value.GetValue(obj, null);

/*					if (val is Enum)
 *                                              val = Convert.ChangeType (val, typeof(int));*/
                    cmd.Parameters.AddWithValue(fp, val);
                }
                sql.Remove(sql.Length - 1, 1);

                sql.Append(" WHERE ");
                AppendObjectFilter(map, cmd, obj, sql);

                cmd.CommandText = sql.ToString();
                return(cmd.ExecuteNonQuery() > 0);
            }
        }
Beispiel #4
0
 /// <summary>
 /// Создание регулярной матрицы глубин.
 /// </summary>
 /// <param name="map">Карта.</param>
 /// <param name="scale">Масштаб карты (1 : scale).</param>
 /// <param name="regMatrix">Регулярная карта.</param>
 /// <param name="message">Сообщение ошибки.</param>
 /// <returns>Успешно ли создана регулярная матрица глубин.</returns>
 public bool CreateRegMatrix(DbMap map, long scale, out RegMatrix regMatrix, out string message)
 {
     if (!InitRegMatrixWithoutFilling(map, scale, out regMatrix, out message))
     {
         return(false);
     }
     return(StratagyInterpol.FillingRegMatrix(map, ref regMatrix, out message));
 }
Beispiel #5
0
 public static GridMap ToMap(this DbMap db)
 {
     return(new GridMap(
                db.Id, db.Name, db.Description,
                new GridLocation(db.LocationX, db.LocationY, db.LocationZ),
                db.Exits.Select(e => (Exits)e.Direction).ToList()
                ));
 }
Beispiel #6
0
        public static MapStatusPacket Create(DbMap _map)
        {
            var packet = new MapStatusPacket();

            packet.UID  = _map.UID;
            packet.ID   = _map.ID;
            packet.Type = (uint)_map.Type;
            return(packet);
        }
Beispiel #7
0
        public static void InsertObject <T> (this DbConnection gdb, T obj)
        {
            MySqlConnection db = (MySqlConnection)gdb;

            using (MySqlCommand cmd = db.CreateCommand()) {
                DbMap         map = GetMap(obj.GetType());
                StringBuilder sql = new StringBuilder("INSERT INTO `");
                sql.Append(map.Table).Append("` (");
                foreach (string f in map.Keys)
                {
                    if (f != map.IdentityField)
                    {
                        sql.Append(f).Append(',');
                    }
                }
                sql[sql.Length - 1] = ')';
                sql.Append(" VALUES (");

                foreach (var f in map)
                {
                    if (f.Key == map.IdentityField)
                    {
                        continue;
                    }
                    string fp = "@_" + f.Key;
                    sql.Append(fp).Append(',');
                    cmd.Parameters.AddWithValue(fp, f.Value.GetValue(obj, null));
                }
                sql[sql.Length - 1] = ')';
                if (map.IdentityField != null)
                {
                    sql.Append("; SELECT @@IDENTITY");
                }

                cmd.CommandText = sql.ToString();
                if (map.IdentityField == null)
                {
                    cmd.ExecuteNonQuery();
                }
                else
                {
                    using (DbDataReader dr = cmd.ExecuteReader()) {
                        if (dr.Read())
                        {
                            PropertyInfo prop = map[map.IdentityField];
                            object       val  = Convert.ChangeType(dr[0], prop.PropertyType);
                            prop.SetValue(obj, val, null);
                        }
                        else
                        {
                            throw new Exception("Insertion failed");
                        }
                    }
                }
            }
        }
Beispiel #8
0
        private static void AppendDatabaseConfig(DatabaseConfig dbConfig)
        {
            var dbKey = dbConfig.ConfigName.ToLower();

            if (DbMap.ContainsKey(dbKey))
            {
                Logging.LogManager.GetLogger(SqlHelper.SqlLogger).Warn("[DbMap]{0} are covered.", dbConfig.ConfigName);
            }
            DbMap[dbKey] = dbConfig;
        }
Beispiel #9
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="dbName"></param>
        /// <returns></returns>
        public static bool ExistDatabase(string dbName)
        {
            ArgumentAssertion.IsNotNull(dbName, "dbName");
            if (null == DbMap)
            {
                Initialize();
            }

            var dbKey = dbName.ToLower();

            return(DbMap.ContainsKey(dbKey));
        }
Beispiel #10
0
        public Map(DbMap dbMap)
            : base(dbMap.Path)
        {
            m_dbMap = dbMap;

            m_dwBaseIdentity = dbMap.MapDoc;
            m_ulFlag         = dbMap.Type;

            m_kRebirthPoint =
                new KeyValuePair <int, Point>(int.Parse(m_dbMap.RebornMap.ToString()),
                                              new Point(int.Parse(m_dbMap.PortalX.ToString()), int.Parse(m_dbMap.PortalY.ToString())));
        }
Beispiel #11
0
        static DbMap GetMap(Type t)
        {
            DbMap map;

            lock (maps) {
                if (maps.TryGetValue(t, out map))
                {
                    return(map);
                }

                List <string> keys = new List <string> ();
                map = new DbMap();
                foreach (PropertyInfo prop in t.GetProperties(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance))
                {
                    DataMemberAttribute dm = (DataMemberAttribute)Attribute.GetCustomAttribute(prop, typeof(DataMemberAttribute));
                    if (dm != null)
                    {
                        string fn;
                        if (!string.IsNullOrEmpty(dm.Field))
                        {
                            fn = dm.Field;
                        }
                        else
                        {
                            fn = prop.Name;
                        }
                        map[fn] = prop;
                        if (dm.Identity)
                        {
                            map.IdentityField = fn;
                        }
                        if (dm.Key || dm.Identity)
                        {
                            keys.Add(fn);
                        }
                    }
                }

                DataTypeAttribute dt = (DataTypeAttribute)Attribute.GetCustomAttribute(t, typeof(DataTypeAttribute));
                if (dt != null && !string.IsNullOrEmpty(dt.Table))
                {
                    map.Table = dt.Table;
                }
                else
                {
                    map.Table = t.Name;
                }
                map.KeyFields = keys.ToArray();
                maps[t]       = map;
                return(map);
            }
        }
Beispiel #12
0
        /// <summary>
        /// Creates a new map.
        /// </summary>
        /// <param name="map">The database map associated with it.</param>
        public Map(DbMap map)
        {
            // Sets controller
            Map = this;

            // Default data ...
            _map = map;
            _id  = -1;

            Players            = new ConcurrentDictionary <uint, Models.Entities.Player>();
            MapObjects         = new ConcurrentDictionary <uint, IMapObject>();
            DefaultCoordinates = new ConcurrentDictionary <string, DbDefaultCoordinate>();
            Drops = new ConcurrentBag <Drop>();
        }
        /// <summary>
        /// Заполнение регулярной матрицы глубин точками с помощью метода RBF.
        /// </summary>
        /// <param name="map">Карта.</param>
        /// <param name="regMatrix">Регулярная карта.</param>
        /// <param name="message">Сообщение ошибки.</param>
        /// <returns>Успешно ли заполнена регулярная матрица глубин.</returns>
        public bool FillingRegMatrix(DbMap map, ref RegMatrix.RegMatrix regMatrix, out string message)
        {
            message = string.Empty;
            if (Setting == null)
            {
                message = "Отсутствует конфигурация для построения регулярной матрицы глубин.";
                return(false);
            }

            try
            {
                RegMatrix.RegMatrix matrix = regMatrix;

                // Заполенение регулярной матрицы.
                // (x, y) - координаты в секундах.
                //for (long y = 0; y < matrix.Length; ++y)
                Parallel.For(0, matrix.Length, y =>
                {
                    //for (long x = 0; x < matrix.Width; ++x)
                    Parallel.For(0, matrix.Width, x =>
                    {
                        var findIndex = Array.FindIndex(map.CloudPoints, point => point.X == x && point.Y == y);
                        if (findIndex != -1)
                        {
                            matrix.Points[y * matrix.Width + x] = new PointRegMatrix
                            {
                                IsSource = true,
                                Depth    = map.CloudPoints[findIndex].Depth
                            }
                        }
                        ;
                        else
                        {
                            matrix.Points[y * matrix.Width + x] = new PointRegMatrix
                            {
                                IsSource = false,
                                Depth    = RBF(x, y, map.CloudPoints)
                            }
                        };
                    });
                });
            }
            catch (Exception ex)
            {
                message = $"Ошибка во время создания регулярной матрицы. {Methods.CalcMessageException(ex)}";
                return(false);
            }

            return(true);
        }
Beispiel #14
0
        public static void DeleteObject <T> (this DbConnection gdb, T obj)
        {
            MySqlConnection db = (MySqlConnection)gdb;

            using (MySqlCommand cmd = db.CreateCommand()) {
                DbMap         map = GetMap(obj.GetType());
                StringBuilder sql = new StringBuilder("DELETE FROM `");
                sql.Append(map.Table).Append("` WHERE ");
                AppendObjectFilter(map, cmd, obj, sql);
                Console.WriteLine(sql);
                cmd.CommandText = sql.ToString();
                cmd.ExecuteNonQuery();
            }
        }
Beispiel #15
0
        public void AddTestCase(DbMap dbMap, SettingGen settingGen, long scale)
        {
            _maxIdTestCase++;
            TestCase testCase = new TestCase
            {
                Id         = _maxIdTestCase,
                DbMap      = dbMap,
                SettingGen = settingGen,
                Scale      = scale
            };

            testCase.TestFinished += TestFinishedAction;

            _testCases.Add(testCase);
        }
Beispiel #16
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="dbName"></param>
        /// <returns></returns>
        public static DatabaseConfig GetDatabase(string dbName)
        {
            Initialize();

            ArgumentAssertion.IsNotNull(dbName, "dbName");

            var dbKey = dbName.ToLower();

            if (DbMap.ContainsKey(dbKey) == false)
            {
                throw new ArgumentOutOfRangeException("dbName", dbName, string.Format("没有定义数据库 - {0}", dbName));
            }

            return(DbMap[dbKey]);
        }
Beispiel #17
0
        static T ReadObject <T> (DbMap map, DbDataReader r) where T : new ()
        {
            T obj = new T();

            foreach (KeyValuePair <string, PropertyInfo> prop in map)
            {
                object val = r[prop.Key];
                if (val is DBNull)
                {
                    prop.Value.SetValue(obj, null, null);
                }
                else
                {
                    prop.Value.SetValue(obj, val, null);
                }
            }
            return(obj);
        }
Beispiel #18
0
        public void Run()
        {
            try
            {
                IMGAlgoritm mgAlgoritm = new CLMGAlgoritm(SettingGen);
                DbMap       outDbMap;
                string      message;

                Stopwatch stopwatch = new Stopwatch();
                stopwatch.Reset();
                stopwatch.Start();
                bool isSuccess = mgAlgoritm.Execute(Scale, DbMap, out outDbMap, out message);
                stopwatch.Stop();

                TestResult testResult = new TestResult
                {
                    IdTestCase = Id,
                    Time       = stopwatch.ElapsedMilliseconds,
                    IsSuccess  = isSuccess
                };

                string dirResultTests = $"{ResourceModel.DIR_TESTS}\\Test_{Id}";
                if (!Directory.Exists(dirResultTests))
                {
                    Directory.CreateDirectory(dirResultTests);
                }
                // Отрисовываем исходную карту.
                Methods.DeleteAllElementsOnDirectry(dirResultTests);
                DbMap.DrawToBMP($"{dirResultTests}\\{ResourceModel.FILENAME_BEFORE_BMP}");

                // Отрисовываем результирующую карту.
                DbMap.DrawToBMP(mgAlgoritm.Clusters, $"{dirResultTests}\\{ResourceModel.FILENAME_AFTER_BMP}");

                // Сохраняем в файл результаты теста с настройкой.
                string distScaleInfo = $"Масштаб теста: 1:{Scale}";
                string testInfo      = $"{DbMap}\n{distScaleInfo}\n{SettingGen}\n{testResult}";
                File.WriteAllText($"{dirResultTests}\\{ResourceModel.FILENAME_TESTINFO}", testInfo);

                TestFinished?.Invoke(testResult);
            }
            catch (Exception ex)
            {
            }
        }
Beispiel #19
0
        static void AppendObjectFilter(DbMap map, MySqlCommand cmd, object obj, StringBuilder sql)
        {
            int n = 0;

            foreach (var prop in map)
            {
                if (map.KeyFields.Length != 0 && !map.KeyFields.Contains(prop.Key))
                {
                    continue;
                }
                if (n > 0)
                {
                    sql.Append(" AND ");
                }
                sql.Append(prop.Key).Append("=@__v" + n);
                cmd.Parameters.AddWithValue("@__v" + n, prop.Value.GetValue(obj, null));
                n++;
            }
        }
Beispiel #20
0
        public static T ReadSettings <T> (this DbConnection gdb) where T : new ()
        {
            T               obj = new T();
            DbMap           map = GetMap(typeof(T));
            MySqlConnection db  = (MySqlConnection)gdb;
            Dictionary <string, PropertyInfo> readProps = new Dictionary <string, PropertyInfo> (map);

            using (MySqlCommand cmd = db.CreateCommand()) {
                cmd.CommandText = "SELECT * FROM `" + map.Table + "`";
                using (DbDataReader dr = cmd.ExecuteReader()) {
                    while (dr.Read())
                    {
                        string       fname = (string)dr["Key"];
                        string       val   = dr["Value"] as string;
                        PropertyInfo prop;
                        if (map.TryGetValue(fname, out prop))
                        {
                            object cval;
                            if (prop.PropertyType.IsEnum)
                            {
                                cval = Enum.Parse(prop.PropertyType, val);
                            }
                            else
                            {
                                cval = Convert.ChangeType(val, prop.PropertyType);
                            }
                            prop.SetValue(obj, cval, null);
                            readProps.Remove(fname);
                        }
                    }
                }
            }
            foreach (PropertyInfo prop in readProps.Values)
            {
                DataMemberAttribute att = (DataMemberAttribute)Attribute.GetCustomAttribute(prop, typeof(DataMemberAttribute), true);
                if (att != null && att.DefaultValue != null)
                {
                    prop.SetValue(obj, att.DefaultValue, null);
                }
            }
            return(obj);
        }
Beispiel #21
0
        /// <summary>
        /// Загрузка карты по его id.
        /// </summary>
        /// <param name="idMap">Id загружаемой карты.</param>
        /// <param name="message">Сообщение с ошибкой.</param>
        /// <returns>Успешно ли прошло загрука.</returns>
        public bool LoadDbMap(int idMap, out string message)
        {
            message = string.Empty;
            Map map;

            Point[] cloudPoints;

            // Загрузка карты.
            if (!_databaseWorker.GetMap(idMap, out map, out message))
            {
                return(false);
            }
            // Загрузка облака точек.
            if (!_databaseWorker.GetPoints(idMap, out cloudPoints, out message))
            {
                return(false);
            }

            try
            {
                // Сохраняем карту.
                SourceSeaMap = new DbMap(map.Name, map.Width, map.Length, map.Scale, map.Latitude, map.Longitude, cloudPoints);

                // Отрисовываем в файл.
                Methods.DeleteAllElementsOnDirectry(ResourceModel.DIR_RUNTIME);
                SourceSeaMap.DrawToBMP($"{ResourceModel.DIR_RUNTIME}Before.bmp");

                // Выставляем, что необходимо отрисовывать исходную карту.
                _isUseSourceMap = true;
            }
            catch (Exception ex)
            {
                message = Methods.CalcMessageException(ex);
                return(false);
            }
            return(true);
        }
Beispiel #22
0
        public static IEnumerable <T> SelectObjects <T> (this DbConnection gdb, string sql, params object[] args) where T : new ()
        {
            List <T>        res = new List <T> ();
            MySqlConnection db  = (MySqlConnection)gdb;

            using (MySqlCommand cmd = db.CreateCommand()) {
                DbMap map = GetMap(typeof(T));
                if (sql == "*")
                {
                    // Select all
                    sql = "SELECT * FROM `" + map.Table + "`";
                }
                else if (sql.StartsWith("*"))
                {
                    // Select with a where
                    sql = "SELECT * FROM `" + map.Table + "` WHERE " + sql.Substring(1);
                }
                else if (sql == ".")
                {
                    // Select by id
                    if (map.KeyFields.Length != 1)
                    {
                        throw new NotSupportedException();
                    }
                    sql = "SELECT * FROM `" + map.Table + "` WHERE " + map.KeyFields[0] + " = {0}";
                }
                GenerateSqlCommand(cmd, sql, args);

                using (DbDataReader dr = cmd.ExecuteReader()) {
                    while (dr.Read())
                    {
                        res.Add(ReadObject <T> (map, dr));
                    }
                }
            }
            return(res);
        }
Beispiel #23
0
        public static void WriteSettings <T> (this DbConnection gdb, T obj) where T : new ()
        {
            DbMap           map = GetMap(typeof(T));
            MySqlConnection db  = (MySqlConnection)gdb;

            foreach (KeyValuePair <string, PropertyInfo> prop in map)
            {
                object val = prop.Value.GetValue(obj, null);
                if (val == null)
                {
                    DataMemberAttribute att = (DataMemberAttribute)Attribute.GetCustomAttribute(prop.Value, typeof(DataMemberAttribute), true);
                    if (att != null)
                    {
                        val = att.DefaultValue;
                    }
                }

                if (val != null)
                {
                    val = val.ToString();
                }

                using (MySqlCommand cmd = db.CreateCommand()) {
                    GenerateSqlCommand(cmd, "UPDATE `" + map.Table + "` SET `Value`={0} WHERE `Key`={1}", val, prop.Key);
                    int count = cmd.ExecuteNonQuery();
                    if (count > 0)
                    {
                        continue;
                    }
                }
                using (MySqlCommand cmd = db.CreateCommand()) {
                    // New property. It has to be inserted
                    GenerateSqlCommand(cmd, "INSERT INTO `" + map.Table + "` (`Key`,`Value`) VALUES ({0},{1})", prop.Key, val);
                    cmd.ExecuteNonQuery();
                }
            }
        }
Beispiel #24
0
        /// <summary>
        /// Инициализация регулярной матрицы без заполнения точками.
        /// </summary>
        /// <param name="map">Карта.</param>
        /// <param name="scale">Масштаб карты (1 : scale).</param>
        /// <param name="regMatrix">Регулярная карта.</param>
        /// <param name="message">Сообщение ошибки.</param>
        /// <returns>Успешно ли прошла инициализация.</returns>
        private bool InitRegMatrixWithoutFilling(DbMap map, long scale, out RegMatrix regMatrix, out string message)
        {
            regMatrix = new RegMatrix();
            message   = string.Empty;

            // Инициализация регулярной матрицы.
            try
            {
                regMatrix.Step = _scaleCoeffDict[scale];

                regMatrix.Width = (int)map.Width + 1;

                regMatrix.Length = (int)map.Length + 1;

                regMatrix.Points = new PointRegMatrix[regMatrix.Width * regMatrix.Length];
            }
            catch (Exception ex)
            {
                message = $"Ошибка во время инициализации регулярной матрицы. {Methods.CalcMessageException(ex)}";
                return(false);
            }

            return(true);
        }
Beispiel #25
0
        public static T ReadObject <T> (this DbConnection gdb, DbDataReader r) where T : new ()
        {
            DbMap map = GetMap(typeof(T));

            return(ReadObject <T> (map, r));
        }
Beispiel #26
0
 /// <summary>
 /// Creates a new dynamic map controller.
 /// </summary>
 /// <param name="map">The database map tied to it.</param>
 public DynamicMapController(DbMap map)
     : base(map)
 {
 }
Beispiel #27
0
 public DbMapingAttribute(DbMap map)
 {
     Map = map;
 }
Beispiel #28
0
        public static (List <GraphNodeDTO>, List <GraphLinkDTO>) GenerateD3Network(Stream file, string DGML_Type_ID)
        {
            XmlDocument doc = new XmlDocument();

            doc.Load(file);
            string json = JsonConvert.SerializeXmlNode(doc);
            List <GraphNodeDTO> nodes = new List <GraphNodeDTO>();
            List <GraphLinkDTO> links = new List <GraphLinkDTO>();

            if (DGML_Type_ID.Equals("DB"))
            {
                DbMap CurrentDBMap = DbMap.FromJson(json);

                for (int i = 0; i < CurrentDBMap.DirectedGraph.Nodes.Node.Length; i++)
                {
                    if (CurrentDBMap.DirectedGraph.Nodes.Node[i].Category == Id.Table)
                    {
                        nodes.Add(new GraphNodeDTO
                        {
                            color = "#7a89de",
                            group = "1",
                            id    = CurrentDBMap.DirectedGraph.Nodes.Node[i].Id,
                            name  = CurrentDBMap.DirectedGraph.Nodes.Node[i].Id
                        });
                    }
                    else if (CurrentDBMap.DirectedGraph.Nodes.Node[i].Category == Id.ForeignKey)
                    {
                        nodes.Add(new GraphNodeDTO
                        {
                            color = "#e3176f",
                            group = "1",
                            id    = CurrentDBMap.DirectedGraph.Nodes.Node[i].Id,
                            name  = CurrentDBMap.DirectedGraph.Nodes.Node[i].Id
                        });
                    }
                    else
                    {
                        nodes.Add(new GraphNodeDTO
                        {
                            color = "#9f85a6",
                            group = "1",
                            id    = CurrentDBMap.DirectedGraph.Nodes.Node[i].Id,
                            name  = CurrentDBMap.DirectedGraph.Nodes.Node[i].Id
                        });
                    }
                }
                for (int i = 0; i < CurrentDBMap.DirectedGraph.Links.Link.Length; i++)
                {
                    links.Add(new GraphLinkDTO
                    {
                        source = CurrentDBMap.DirectedGraph.Links.Link[i].Source,
                        target = CurrentDBMap.DirectedGraph.Links.Link[i].Target
                    });
                }
            }
            else if (DGML_Type_ID.Equals("CODE"))
            {
                CodeMap CurrentDBMap = CodeMap.FromJson(json);
                for (int i = 0; i < CurrentDBMap.DirectedGraph.Nodes.Node.Length; i++)
                {
                    nodes.Add(new GraphNodeDTO
                    {
                        color = "#7a89de",
                        group = "1",
                        id    = CurrentDBMap.DirectedGraph.Nodes.Node[i].Id,
                        name  = CurrentDBMap.DirectedGraph.Nodes.Node[i].Label
                    });
                }
                for (int i = 0; i < CurrentDBMap.DirectedGraph.Links.Link.Length; i++)
                {
                    links.Add(new GraphLinkDTO
                    {
                        source = CurrentDBMap.DirectedGraph.Links.Link[i].Source,
                        target = CurrentDBMap.DirectedGraph.Links.Link[i].Target
                    });
                }
            }
            return(nodes, links);
        }