public ActionResult FileUpload(HttpPostedFileBase file)
        {
            if (ModelState.IsValid)
            {
                if (file == null)
                {
                    ModelState.AddModelError("File", "Please Upload Your file");
                }
                else if (file.ContentLength > 0)
                {
                    int      MaxContentLength      = 1024 * 1024 * 3; //3 MB
                    string[] AllowedFileExtensions = new string[] { ".txt" };

                    if (!AllowedFileExtensions.Contains(file.FileName.Substring(file.FileName.LastIndexOf('.'))))
                    {
                        ModelState.AddModelError("File", "Please file of type: " + string.Join(", ", AllowedFileExtensions));
                    }

                    else if (file.ContentLength > MaxContentLength)
                    {
                        ModelState.AddModelError("File", "Your file is too large, maximum allowed size is: " + MaxContentLength + " MB");
                    }
                    else
                    {
                        List <string> list = new List <string>();
                        using (StreamReader reader = new StreamReader(file.InputStream))
                        {
                            string line;
                            while ((line = reader.ReadLine()) != null)
                            {
                                list.Add(line); // Add to list.
                            }
                        }
                        List <ViewModelNewConnection> newConnectionList = new List <ViewModelNewConnection>();
                        foreach (var line in list)
                        {
                            var items   = line.Split(';');
                            var connect = new ViewModelNewConnection();
                            //stringline = line.Id + "; " + line.Distance + "; " + line.FromStationId + "; " + line.ToStationId + "; " + line.RouteId + "; " + line.OldId;
                            connect.Id            = Convert.ToInt32(items[0].Trim());
                            connect.Distance      = Convert.ToInt32(items[1].Trim());
                            connect.FromStationId = Convert.ToInt32(items[2].Trim());
                            connect.ToStationId   = Convert.ToInt32(items[3].Trim());
                            connect.RouteId       = Convert.ToInt32(items[4].Trim());
                            connect.OldId         = Convert.ToInt32(items[5].Trim());
                            newConnectionList.Add(connect);
                        }
                        while (Graph.InitCompleted == false)
                        {
                        }
                        var model = _IPathSearchService.ChangeNewConnectionToOld(newConnectionList);

                        return(View(model));
                    }
                }
            }
            return(View());
        }
        public List <List <ViewModelConnection> > LabelingSetting(List <int> sourceIdList, List <int> sinkIdList)
        {
            //var watch = System.Diagnostics.Stopwatch.StartNew();
            List <ViewModelStation>           oldStationList    = Graph.oldStationList;
            List <ViewModelConnection>        oldConnectionList = Graph.oldConnectionList;
            List <ViewModelRoute>             oldRouteList      = Graph.oldRouteList;
            List <ViewModelNewConnection>     newConnectionList = Graph.newConnectionList;
            List <ViewModelNewStation>        newStationList    = Graph.newStationList;
            IDictionary <int, List <Vertex> > fanOut            = Graph.fanOut;

            List <List <Vertex> >      pathList    = new List <List <Vertex> >();
            List <ViewModelNewStation> sinkStation = newStationList.Where(x => sinkIdList.Contains(x.OldId) && (x.outVertex == false || x.outVertex == null)).ToList();
            var sink = new Dictionary <int, int>();

            for (int k = 0; k < sinkStation.Count; k++)
            {
                sink.Add(sinkStation[k].Id, sinkStation[k].Id);
            }
            ;

            List <ViewModelNewStation> sourceStation = newStationList.Where(x => sourceIdList.Contains(x.OldId) && (x.outVertex == true)).ToList();
            List <Vertex> allSourceVertex            = new List <Vertex>();

            foreach (var stat in sourceStation)
            {
                var source = new Vertex()
                {
                    Id             = stat.Id,
                    SourceDistance = 0
                };
                allSourceVertex.Add(source);
            }
            foreach (var source in allSourceVertex)
            {
                List <Vertex> queue0 = new List <Vertex>();
                queue0.Add(source);
                // init queue
                SortedDictionary <int, List <Vertex> > Queue = new SortedDictionary <int, List <Vertex> >();
                Dictionary <int, int> QueueIdList            = new Dictionary <int, int>();
                Queue.Add(source.SourceDistance, queue0);
                QueueIdList.Add(source.Id, source.SourceDistance);

                var result = new Dictionary <int, Vertex>();
                while (Queue.Count != 0)
                {
                    Vertex u    = Queue.ElementAt(0).Value.ElementAt(0);
                    var    item = Queue.ElementAt(0).Value;
                    result.Add(u.Id, u);
                    if (sink.ContainsKey(u.Id))
                    {
                        break;
                    }
                    //remove minimum item in queue
                    if (item.Count < 2)
                    {
                        Queue.Remove(u.SourceDistance);
                    }
                    else
                    {
                        item.RemoveAt(0);
                    }
                    QueueIdList.Remove(u.Id);

                    // check neighbor
                    if (fanOut.ContainsKey(u.Id))
                    {
                        List <Vertex> neigbourVertexs = fanOut[u.Id];
                        for (int ii = 0; ii < neigbourVertexs.Count; ii++)
                        {
                            bool checkExistKey = QueueIdList.ContainsKey(neigbourVertexs[ii].Id);
                            // don't stay in queue
                            if (!checkExistKey)
                            {
                                // don't stay in result => new vertex
                                if (!result.ContainsKey(neigbourVertexs[ii].Id))
                                {
                                    Vertex vertex = new Vertex()
                                    {
                                        Id             = neigbourVertexs[ii].Id,
                                        SourceDistance = u.SourceDistance + neigbourVertexs[ii].SourceDistance,
                                        ParentId       = u.Id
                                    };
                                    if (Queue.ContainsKey(vertex.SourceDistance))
                                    {
                                        Queue[vertex.SourceDistance].Add(vertex);
                                        QueueIdList.Add(vertex.Id, vertex.SourceDistance);
                                    }
                                    else
                                    {
                                        List <Vertex> queueV = new List <Vertex>();
                                        queueV.Add(vertex);
                                        Queue.Add(vertex.SourceDistance, queueV);
                                        QueueIdList.Add(vertex.Id, vertex.SourceDistance);
                                    }
                                }
                                //else it has been result that mean it's minimum
                            }
                            else
                            {
                                Vertex v = Queue[QueueIdList[neigbourVertexs[ii].Id]].Where(x => x.Id == neigbourVertexs[ii].Id).FirstOrDefault();

                                if (v.SourceDistance > u.SourceDistance + neigbourVertexs[ii].SourceDistance)
                                {
                                    //remove v
                                    if (Queue[QueueIdList[neigbourVertexs[ii].Id]].Count < 2)
                                    {
                                        Queue.Remove(QueueIdList[neigbourVertexs[ii].Id]);
                                    }
                                    else
                                    {
                                        Queue[QueueIdList[neigbourVertexs[ii].Id]].Remove(v);
                                    }
                                    QueueIdList.Remove(v.Id);

                                    // add new v into queue
                                    Vertex vertex = new Vertex()
                                    {
                                        Id             = neigbourVertexs[ii].Id,
                                        SourceDistance = u.SourceDistance + neigbourVertexs[ii].SourceDistance,
                                        ParentId       = u.Id
                                    };
                                    if (Queue.ContainsKey(vertex.SourceDistance))
                                    {
                                        Queue[vertex.SourceDistance].Add(vertex);
                                        QueueIdList.Add(vertex.Id, vertex.SourceDistance);
                                    }
                                    else
                                    {
                                        List <Vertex> queueV = new List <Vertex>();
                                        queueV.Add(vertex);
                                        Queue.Add(vertex.SourceDistance, queueV);
                                        QueueIdList.Add(vertex.Id, vertex.SourceDistance);
                                    }
                                }
                            }
                        }
                    }
                }

                List <Vertex> path = new List <Vertex>();
                Vertex        temp = result.LastOrDefault().Value;
                while (true)
                {
                    path.Add(temp);
                    if (temp.Id == source.Id)
                    {
                        break;
                    }
                    temp = result[temp.ParentId];
                }
                pathList.Add(path);
            }
            if (pathList.Count == 0)
            {
                return(null);
            }

            int           min       = Int32.MaxValue;
            List <Vertex> finalpath = new List <Vertex>();

            for (int o = 0; o < pathList.Count; o++)
            {
                if (min > pathList[o][0].SourceDistance)
                {
                    min       = pathList[o][0].SourceDistance;
                    finalpath = pathList[o];
                }
            }
            List <ViewModelNewConnection> newConResult = new List <ViewModelNewConnection>();

            for (int i = 0; i < finalpath.Count - 1; i++)
            {
                ViewModelNewConnection newcon = newConnectionList.Where(x => x.ToStationId == finalpath[i].Id && x.FromStationId == finalpath[i + 1].Id).FirstOrDefault();
                if (newcon != null)
                {
                    newConResult.Add(newcon);
                }
            }

            //using (System.IO.StreamWriter file =
            //new System.IO.StreamWriter(@"D:\test1.txt"))
            //{
            //    foreach (var line in newConResult)
            //    {
            //        string stringline = "";
            //        stringline = line.Id + "; " + line.Distance + "; " + line.FromStationId + "; " + line.ToStationId + "; " + line.RouteId + "; " + line.OldId;
            //        file.WriteLine(stringline);
            //    }
            //}

            var pathResult = ChangeNewConnectionToOld(newConResult);

            //watch.Stop();
            //var elapsedMs = watch.ElapsedMilliseconds;
            return(pathResult);
        }
Exemplo n.º 3
0
        public static void CreateNewGraph()
        {
            int indexCon = 0;

            //new connection list
            foreach (var route in oldRouteList)
            {
                List <ViewModelConnection> tempconnectionList;
                for (int j = 0; j < 2; j++)
                {
                    tempconnectionList = oldConnectionList.Where(x => x.RouteId == route.Id && x.Arrive == Convert.ToBoolean(j)).OrderBy(x => x.Order).ToList();
                    //from A to B
                    for (int i = 0; i < tempconnectionList.Count - 1; i++)
                    {
                        ViewModelNewConnection newCon = new ViewModelNewConnection();
                        newCon.Id            = indexCon++;
                        newCon.Distance      = tempconnectionList[i + 1].Distance;
                        newCon.FromStationId = tempconnectionList[i].StationId;
                        newCon.ToStationId   = tempconnectionList[i + 1].StationId;
                        newCon.RouteId       = tempconnectionList[i + 1].RouteId;
                        newCon.OldId         = tempconnectionList[i + 1].Id;
                        newConnectionList.Add(newCon);
                    }
                }
            }

            newStationList = new List <ViewModelNewStation>();
            int indexVertex = oldStationList.Count + 1;

            for (int i = 0; i < oldStationList.Count; i++)
            {
                //list fan in connection
                List <ViewModelNewConnection> faninConList = newConnectionList.Where(x => x.ToStationId == oldStationList[i].Id).ToList();

                //list fan out connection
                List <ViewModelNewConnection> fanoutConList = newConnectionList.Where(x => x.FromStationId == oldStationList[i].Id).ToList();

                //it's not cross or T cross
                if (faninConList.Count < 2 && fanoutConList.Count < 2)
                {
                    //do no thing
                    ViewModelNewStation newstation = new ViewModelNewStation();
                    newstation.Id    = oldStationList[i].Id;
                    newstation.OldId = oldStationList[i].Id;
                    newStationList.Add(newstation);
                }
                // it's cross
                else
                {
                    List <ViewModelNewStation> faninVertexList = new List <ViewModelNewStation>();
                    // add fan in station
                    for (int j = 0; j < faninConList.Count; j++)
                    {
                        ViewModelNewStation inS = new ViewModelNewStation();
                        inS.Id        = indexVertex++;
                        inS.OldId     = oldStationList[i].Id;
                        inS.outVertex = false;
                        faninVertexList.Add(inS);
                        newStationList.Add(inS);
                    }

                    //list fan out station
                    List <ViewModelNewStation> fanoutVertexList = new List <ViewModelNewStation>();
                    // add fan out station
                    for (int j = 0; j < fanoutConList.Count; j++)
                    {
                        ViewModelNewStation outS = new ViewModelNewStation();
                        outS.Id        = indexVertex++;
                        outS.OldId     = oldStationList[i].Id;
                        outS.outVertex = true;
                        fanoutVertexList.Add(outS);
                        newStationList.Add(outS);
                    }

                    // map new fan in connection
                    for (int j = 0; j < faninConList.Count; j++)
                    {
                        ViewModelNewConnection con = newConnectionList.Where(x => x.ToStationId == oldStationList[i].Id && x.FromStationId == faninConList[j].FromStationId).FirstOrDefault();
                        con.ToStationId = faninVertexList[j].Id;
                    }

                    // map new fan out connection
                    for (int j = 0; j < fanoutConList.Count; j++)
                    {
                        ViewModelNewConnection con = newConnectionList.Where(x => x.FromStationId == oldStationList[i].Id && x.FromStationId == fanoutConList[j].FromStationId).FirstOrDefault();
                        con.FromStationId = fanoutVertexList[j].Id;
                    }

                    //map fan in to fan out
                    for (int j = 0; j < faninVertexList.Count; j++)
                    {
                        for (int k = 0; k < fanoutVertexList.Count; k++)
                        {
                            // the same route
                            if (faninConList[j].RouteId == fanoutConList[k].RouteId)
                            {
                                ViewModelNewConnection newCon = new ViewModelNewConnection();
                                newCon.Id            = indexCon++;
                                newCon.Distance      = 0;
                                newCon.FromStationId = faninConList[j].ToStationId;
                                newCon.ToStationId   = fanoutConList[k].FromStationId;
                                newCon.RouteId       = faninConList[j].RouteId;
                                newConnectionList.Add(newCon);
                            }
                            else
                            {
                                ViewModelNewConnection newCon = new ViewModelNewConnection();
                                newCon.Id            = indexCon++;
                                newCon.Distance      = Convert.ToInt32(ConfigurationManager.AppSettings["ChangeRoutePunishment"]);
                                newCon.FromStationId = faninConList[j].ToStationId;
                                newCon.ToStationId   = fanoutConList[k].FromStationId;
                                newCon.RouteId       = faninConList[j].RouteId;
                                newConnectionList.Add(newCon);
                            }
                        }
                    }
                }
            }
            //build fanout
            foreach (var station in newStationList)
            {
                List <Vertex> neighbor      = new List <Vertex>();
                var           routePassList = newConnectionList.Where(x => x.FromStationId.HasValue && x.FromStationId.Value == station.Id).ToList();
                if (routePassList.Count > 0)
                {
                    foreach (var routePass in routePassList)
                    {
                        var neighborVertex = new Vertex()
                        {
                            Id             = routePass.ToStationId.Value,
                            SourceDistance = routePass.Distance,
                            ParentId       = station.Id,
                            ConnectionId   = routePass.Id
                        };
                        neighbor.Add(neighborVertex);
                    }
                    //add fanout
                    fanOut.Add(station.Id, neighbor);
                }
            }

            //using (System.IO.StreamWriter file =
            //new System.IO.StreamWriter(@"D:\vertex.txt"))
            //{
            //    foreach (var line in newStationList)
            //    {
            //        string stringline = "";
            //        stringline = line.Id + "; " + line.OldId + "; " + line.outVertex;
            //        file.WriteLine(stringline);
            //    }
            //}

            //using (System.IO.StreamWriter file =
            //new System.IO.StreamWriter(@"D:\edge.txt"))
            //{
            //    foreach (var line in newConnectionList)
            //    {
            //        string stringline = "";
            //        stringline = line.Id + "; " + line.Distance + "; " + line.FromStationId + "; " + line.ToStationId + "; " + line.RouteId + "; " + line.OldId;
            //        file.WriteLine(stringline);
            //    }
            //}
            //using (var rep = new NewStationRepository())
            //{
            //    List<NewStation> res = Mapper.Map<List<ViewModelNewStation>, List<NewStation>>(newStationList);
            //    foreach (var i in res)
            //    {
            //        rep.InsertOrUpdate(i);
            //    }
            //    rep.Save();
            //}
            //using (var rep = new NewConnectionRepository())
            //{
            //    List<NewConnection> res = Mapper.Map<List<ViewModelNewConnection>, List<NewConnection>>(newConnectionList);
            //    foreach (var i in res)
            //    {
            //        rep.InsertOrUpdate(i);
            //    }
            //    rep.Save();
            //}
        }
Exemplo n.º 4
0
        public static void CreateNewWalkingGraph()
        {
            string pathConnection = HttpContext.Current.Server.MapPath("~/App_Data/Graph/Connection.xml");
            string pathStation    = HttpContext.Current.Server.MapPath("~/App_Data/Graph/Station.xml");
            string pathFanout     = HttpContext.Current.Server.MapPath("~/App_Data/Graph/Fanout.xml");

            if (!File.Exists(pathConnection) || !File.Exists(pathStation) || !File.Exists(pathFanout))
            {
                int indexCon = 0;
                //new connection list
                foreach (var route in oldRouteList)
                {
                    List <ViewModelConnection> tempconnectionList;
                    for (int j = 0; j < 2; j++)
                    {
                        tempconnectionList = oldConnectionList.Where(x => x.RouteId == route.Id && x.Arrive == Convert.ToBoolean(j)).OrderBy(x => x.Order).ToList();
                        //from A to B
                        for (int i = 0; i < tempconnectionList.Count - 1; i++)
                        {
                            ViewModelNewConnection newCon = new ViewModelNewConnection();
                            newCon.Id            = indexCon++;
                            newCon.Distance      = tempconnectionList[i + 1].Distance;
                            newCon.FromStationId = tempconnectionList[i].StationId;
                            newCon.ToStationId   = tempconnectionList[i + 1].StationId;
                            newCon.RouteId       = tempconnectionList[i + 1].RouteId;
                            newCon.OldId         = tempconnectionList[i + 1].Id;
                            newCon.PolyLine      = tempconnectionList[i + 1].PolyLine;
                            newCon.Type          = 1;
                            newConnectionList.Add(newCon);
                        }
                    }
                }

                // add walking connection
                foreach (var item in oldWalkingConnectionList)
                {
                    ViewModelNewConnection newCon = new ViewModelNewConnection();
                    newCon.Id            = indexCon++;
                    newCon.Distance      = item.Distance;
                    newCon.FromStationId = item.FromStationId;
                    newCon.ToStationId   = item.ToStationId;
                    newCon.RouteId       = -1;
                    newCon.OldId         = item.Id;
                    newCon.PolyLine      = item.PolyLine;
                    newCon.Type          = 2;
                    newConnectionList.Add(newCon);
                }

                newStationList = new List <ViewModelNewStation>();
                int indexVertex = oldStationList.Count + 1;
                for (int i = 0; i < oldStationList.Count; i++)
                {
                    //list fan in connection
                    List <ViewModelNewConnection> faninConList = newConnectionList.Where(x => x.ToStationId == oldStationList[i].Id).ToList();

                    //list fan out connection
                    List <ViewModelNewConnection> fanoutConList = newConnectionList.Where(x => x.FromStationId == oldStationList[i].Id).ToList();

                    //it's not cross or T cross
                    if (faninConList.Count < 2 && fanoutConList.Count < 2)
                    {
                        //do no thing
                        ViewModelNewStation newstation = new ViewModelNewStation();
                        newstation.Id    = oldStationList[i].Id;
                        newstation.OldId = oldStationList[i].Id;
                        newStationList.Add(newstation);
                    }
                    // it's cross
                    else
                    {
                        List <ViewModelNewStation> faninVertexList = new List <ViewModelNewStation>();
                        // add fanin station
                        for (int j = 0; j < faninConList.Count; j++)
                        {
                            ViewModelNewStation inS = new ViewModelNewStation();
                            inS.Id        = indexVertex++;
                            inS.OldId     = oldStationList[i].Id;
                            inS.outVertex = false;
                            faninVertexList.Add(inS);
                            newStationList.Add(inS);
                        }

                        //list fan out station
                        List <ViewModelNewStation> fanoutVertexList = new List <ViewModelNewStation>();
                        // add fan out station
                        for (int j = 0; j < fanoutConList.Count; j++)
                        {
                            ViewModelNewStation outS = new ViewModelNewStation();
                            outS.Id        = indexVertex++;
                            outS.OldId     = oldStationList[i].Id;
                            outS.outVertex = true;
                            fanoutVertexList.Add(outS);
                            newStationList.Add(outS);
                        }

                        // map new fan in connection
                        for (int j = 0; j < faninConList.Count; j++)
                        {
                            ViewModelNewConnection con = newConnectionList.Where(x => x.ToStationId == oldStationList[i].Id && x.FromStationId == faninConList[j].FromStationId).FirstOrDefault();
                            con.ToStationId = faninVertexList[j].Id;
                        }

                        // map new fan out connection
                        for (int j = 0; j < fanoutConList.Count; j++)
                        {
                            ViewModelNewConnection con = newConnectionList.Where(x => x.FromStationId == oldStationList[i].Id && x.FromStationId == fanoutConList[j].FromStationId).FirstOrDefault();
                            con.FromStationId = fanoutVertexList[j].Id;
                        }

                        //map fan in to fan out
                        for (int j = 0; j < faninVertexList.Count; j++)
                        {
                            for (int k = 0; k < fanoutVertexList.Count; k++)
                            {
                                ViewModelNewConnection newCon = new ViewModelNewConnection();
                                newCon.Id = indexCon++;
                                // the same route
                                if (faninConList[j].RouteId == fanoutConList[k].RouteId)
                                {
                                    if (fanoutConList[k].RouteId == -1)
                                    {
                                        newCon.Distance = Convert.ToInt32(ConfigurationManager.AppSettings["ChangeRoutePunishment"]);
                                    }
                                    else
                                    {
                                        newCon.Distance = 0;
                                    }
                                }
                                else
                                {
                                    if (fanoutConList[k].RouteId == -1)
                                    {
                                        newCon.Distance = Convert.ToInt32(ConfigurationManager.AppSettings["ChangeWalkingRoutePunishment"]);
                                    }
                                    else if (faninConList[j].RouteId != -1)
                                    {
                                        newCon.Distance = Convert.ToInt32(ConfigurationManager.AppSettings["ChangeRoutePunishment"]);
                                    }
                                    else
                                    {
                                        newCon.Distance = 0;
                                    }
                                }
                                newCon.FromStationId = faninConList[j].ToStationId;
                                newCon.ToStationId   = fanoutConList[k].FromStationId;
                                newCon.RouteId       = faninConList[j].RouteId;
                                newConnectionList.Add(newCon);
                            }
                        }
                    }
                }

                //build fanout
                var tempFanouts = new List <ViewModelFanOut>();
                foreach (var station in newStationList)
                {
                    List <Vertex> neighbor      = new List <Vertex>();
                    var           routePassList = newConnectionList.Where(x => x.FromStationId.HasValue && x.FromStationId.Value == station.Id).ToList();
                    if (routePassList.Count > 0)
                    {
                        foreach (var routePass in routePassList)
                        {
                            var neighborVertex = new Vertex()
                            {
                                Id             = routePass.ToStationId.Value,
                                SourceDistance = routePass.Distance,
                                ParentId       = station.Id,
                                ConnectionId   = routePass.Id
                            };
                            neighbor.Add(neighborVertex);
                        }
                        var tempF = new ViewModelFanOut();
                        tempF.StationId = station.Id;
                        tempF.Neighbor  = neighbor;
                        tempFanouts.Add(tempF);
                        //add fanout
                        fanOut.Add(station.Id, neighbor);
                    }
                }

                try
                {
                    //var writer = new System.Xml.Serialization.XmlSerializer(typeof(List<ViewModelNewConnection>),"connection");
                    //var wfile = new System.IO.StreamWriter(pathConnection);
                    //writer.Serialize(wfile, newConnectionList);
                    //wfile.Close();

                    //var writer2 = new System.Xml.Serialization.XmlSerializer(typeof(List<ViewModelNewStation>),"station");
                    //var wfile2 = new System.IO.StreamWriter(pathStation);
                    //writer2.Serialize(wfile2, newStationList);
                    //wfile2.Close();

                    using (StreamWriter myWriter = new StreamWriter(pathConnection, false))
                    {
                        XmlSerializer mySerializer = new XmlSerializer(typeof(List <ViewModelNewConnection>));
                        mySerializer.Serialize(myWriter, newConnectionList);
                    }

                    using (StreamWriter myWriter = new StreamWriter(pathStation, false))
                    {
                        XmlSerializer mySerializer = new XmlSerializer(typeof(List <ViewModelNewStation>));
                        mySerializer.Serialize(myWriter, newStationList);
                    }

                    using (StreamWriter myWriter = new StreamWriter(pathFanout, false))
                    {
                        XmlSerializer mySerializer = new XmlSerializer(typeof(List <ViewModelFanOut>));
                        mySerializer.Serialize(myWriter, tempFanouts);
                    }
                }
                catch (Exception e)
                {
                }
            }
            else
            {
                try
                {
                    System.Xml.Serialization.XmlSerializer reader = new System.Xml.Serialization.XmlSerializer(typeof(List <ViewModelNewConnection>));
                    System.IO.StreamReader file = new System.IO.StreamReader(pathConnection);
                    newConnectionList = (List <ViewModelNewConnection>)reader.Deserialize(file);
                    file.Close();

                    System.Xml.Serialization.XmlSerializer reader2 = new System.Xml.Serialization.XmlSerializer(typeof(List <ViewModelNewStation>));
                    System.IO.StreamReader file2 = new System.IO.StreamReader(pathStation);
                    newStationList = (List <ViewModelNewStation>)reader2.Deserialize(file2);
                    file2.Close();

                    System.Xml.Serialization.XmlSerializer reader3 = new System.Xml.Serialization.XmlSerializer(typeof(List <ViewModelFanOut>));
                    System.IO.StreamReader file3 = new System.IO.StreamReader(pathFanout);
                    var tempFanouts = (List <ViewModelFanOut>)reader3.Deserialize(file3);
                    file3.Close();

                    foreach (var i in tempFanouts)
                    {
                        fanOut.Add(i.StationId, i.Neighbor);
                    }
                }
                catch (Exception e)
                {
                }
            }
        }