Example #1
0
        private CsvWriter GetRouteCsvWriter()
        {
            CsvWriter writer = new CsvWriter();

            writer.Columns.Add("ID");
            writer.Columns.Add("Team");
            writer.Columns.Add("Radius");
            writer.Columns.Add("Actions");
            writer.Columns.Add("Path Actions");

            for (int x = 0; x < _routeControl.Routes.Route.Rows.Count; x++)
            {
                Route route = new Route();
                route.FromRouteRow((Routes.RouteRow)_routeControl.Routes.Route.Rows[x]);

                ArrayList routeRow = new ArrayList();

                routeRow.Add(Convert.ToString(route.ID));
                routeRow.Add(Convert.ToString(route.Team));
                routeRow.Add(Convert.ToString(route.Radius));
                routeRow.Add(Convert.ToString(route.Actions));
                routeRow.Add(Convert.ToString(route.PathActions));

                writer.AddRow(routeRow);
            }

            return(writer);
        }
Example #2
0
        private CsvWriter GetRouteCsvWriter()
        {
            CsvWriter writer = new CsvWriter();

            writer.Columns.Add("ID");
            writer.Columns.Add("Team");
            writer.Columns.Add("Radius");
            writer.Columns.Add("Actions");
            writer.Columns.Add("Path Actions");

            for (int x = 0; x < _routeControl.Routes.Route.Rows.Count; x++)
            {
                Route route = new Route();
                route.FromRouteRow((Routes.RouteRow)_routeControl.Routes.Route.Rows[x]);

                ArrayList routeRow = new ArrayList();

                routeRow.Add(Convert.ToString(route.ID));
                routeRow.Add(Convert.ToString(route.Team));
                routeRow.Add(Convert.ToString(route.Radius));
                routeRow.Add(Convert.ToString(route.Actions));
                routeRow.Add(Convert.ToString(route.PathActions));

                writer.AddRow(routeRow);
            }

            return writer;
        }
Example #3
0
        public void Write(string fileName, Nodes nodes, Actions actions, Routes routes)
        {
            if (File.Exists(fileName))
            {
                // copy the .nav file
                string backupNavFile = fileName + "_" + DateTime.Now.Month + "_" + DateTime.Now.Day + "_" + DateTime.Now.Year + "_" + DateTime.Now.Hour + "_" + DateTime.Now.Minute + "_" + DateTime.Now.Second + ".nav";
                File.Move(fileName, backupNavFile);
                File.SetLastWriteTime(backupNavFile, DateTime.Now);
            }

            FileStream   fs     = File.Create(fileName);
            BinaryWriter writer = new BinaryWriter(fs);

            //byte[] header = new byte[] { 70, 114, 105, 116, 122, 66, 111, 116, 0, 7, 0, 0, 0 };

            writer.Write(_header);
            writer.Write(FromInt(nodes.Node.Count));

            if (nodes.Node.Count > 0)
            {
                int nodeCounter = 0;
                foreach (Nodes.NodeRow nodeRow in nodes.Node)
                {
                    Node node = (Node)_nodes[nodeCounter];
                    node.FromNodeRow(nodeRow);
                    writer.Write(node.ToByteArray());
                    nodeCounter++;
                }

                if (actions.Action.Count > 0)
                {
                    int actionCounter = 0;
                    writer.Write(FromInt(actions.Action.Count));
                    foreach (Actions.ActionRow actionRow in actions.Action)
                    {
                        Action action = (Action)_actions[actionCounter];
                        action.FromActionRow(actionRow);
                        writer.Write(action.ToByteArray());
                        actionCounter++;
                    }

                    if (routes.Route.Count > 0)
                    {
                        int routeCounter = 0;
                        writer.Write(FromInt(routes.Route.Count));
                        foreach (Routes.RouteRow routeRow in routes.Route)
                        {
                            Route route = (Route)_routes[routeCounter];
                            route.FromRouteRow(routeRow);
                            writer.Write(route.ToByteArray());
                            routeCounter++;
                        }
                    }
                    else
                    {
                        writer.Write(FromInt(0));
                    }
                }
                else
                {
                    writer.Write(FromInt(0));
                    writer.Write(FromInt(0));
                }
            }
            else
            {
                writer.Write(FromInt(0));
                writer.Write(FromInt(0));
            }

            writer.Close();
            fs.Close();
        }