예제 #1
0
        public void WriteCSV(DateTime date,
                             List <Planet> warplanetList, List <Planet> planetList)
        {
            string kosmorDate = KosmorMapTool.getKosmorDate();
            string dateString = KosmorMapTool.dateStringBuilder(kosmorDate, date);
            // Uses the kosmorDate to build the dateString
            FileInfo csvDir = new FileInfo("csv");

            if (!csvDir.Exists)
            {
                csvDir.Create();
            }
            String fileName = csvDir + "/" + dateString + (" - csv -.csv");

            // Uses the dateString to create the fileName
            kosmorDate = kosmorDate.Replace("_", "-");
            writer     = new StringWriter();
            writer.Write("# csv for kosmor com day =" + kosmorDate + "\n");
            foreach (Warplanet warplanet in warplanetList)
            {
                writer.Write(warplanet.ToString());
                writer.Write("\n");
            }
            foreach (Planet planet in planetList)
            {
                writer.Write(planet.ToString());
                writer.Write("\n");
            }
            writer.Close();
        }
예제 #2
0
        public static Object[] parseSVG(String kosmorDate, DateTime date)
        {
            /* As it has to return two things, it can not return them
             * directly but has to encapsulate it in another object.
             */
            Object[] bothNodeLists = new Object[2];

            //DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
            //DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();

            String   SVGFileName = "./" + KosmorMapTool.SVGFileName;
            FileInfo svgMap      = new FileInfo(SVGFileName);



            //Document doc = docBuilder.parse(SVGFileName);


            // "text" is the actual planet/warplanet
            Object[] listOfPlanetsAsXMLNode = null; // = doc.getElementsByTagName("text");

            // "line" is the line drawn by a warplanet. Used for calculation of warplanet coordinates.
            Object[] listOfLinesAsXMLNode = null; // = doc.getElementsByTagName("line");
            bothNodeLists[0] = listOfPlanetsAsXMLNode;
            bothNodeLists[1] = listOfLinesAsXMLNode;

            // normalize text representation
            //doc.getDocumentElement().normalize();

            // Build the fileName the .svg should be renamed to, using the dateStringBuilder
            String newSVGFileName = KosmorMapTool.dateStringBuilder(kosmorDate, date);

            newSVGFileName = String.Concat(newSVGFileName, " - Map - kosmor.com - .svg");



            // Making sure the directory does exist, if not, it is created
            DirectoryInfo svgDir = new DirectoryInfo("svg");

            if (!svgDir.Exists)
            {
                svgDir.Create();
            }
            File.Move(svgMap.FullName, Path.Combine(svgDir + "/" + newSVGFileName));


            return(bothNodeLists);
        }
예제 #3
0
        public static void writeHTML(bool doWriteWarplanets, bool doWritePlanets,
                                     bool writeNeutral, DateTime date, NameValueCollection loginData, bool fetchInfo)
        {
            KosmorMapTool.setKosmorDate(date);
            string kosmorDate = KosmorMapTool.getKosmorDate(); // Gets the kosmorDate

            List <Object> warplanetAndPlanetList = PlanetListBuilder.BuildPlanetList(kosmorDate, date, fetchInfo);

            planetList        = (List <Planet>)warplanetAndPlanetList[0];
            warplanetList     = (List <Planet>)warplanetAndPlanetList[1];
            neutralPlanetList = (List <Planet>)warplanetAndPlanetList[2];
            string dateString = KosmorMapTool.dateStringBuilder(kosmorDate, date);
            // Uses the kosmorDate to build the dateString

            //StatusMessageHandler.postStatusMessages(10);

            // Making sure the directory exists, if not, is is created
            DirectoryInfo htmldir = new DirectoryInfo("html");

            if (!htmldir.Exists)
            {
                htmldir.Create();
            }

            string fileName = htmldir + "/" + dateString
                              + (" - Planet & WP List - kosmor.com - .html");
            // Uses the dateString to create the fileName

            StreamWriter fileOut = new StreamWriter(fileName);

            //StatusMessageHandler.postStatusMessages(11);

            initializeHTML(dateString, fileOut);

            HttpClientForKosmor.Login(loginData);

            fileOut.WriteLine("<tbody>");
            fileOut.WriteLine(fileOut.NewLine);
            if (doWriteWarplanets)
            {
                writeWarplanets(fetchInfo, warplanetList, fileOut);
            }
            if (doWritePlanets)
            {
                writePlanets(fetchInfo, planetList, fileOut);
            }

            /*
             * if (writeNeutral) { HTMLBuilder.writeNeutral(fetchInfo,
             * HTMLBuilder.neutralPlanetList, out, httpclient); }
             */
            fileOut.WriteLine("</tbody>");
            fileOut.WriteLine(fileOut.NewLine);
            //httpclient.getConnectionManager().shutdown();
            fileOut.WriteLine("</table>");
            fileOut.WriteLine(fileOut.NewLine);
            importJavaScriptFile(fileOut);
            writeScriptInfo(fileOut);
            fileOut.WriteLine("</form>");
            fileOut.WriteLine(fileOut.NewLine);
            fileOut.WriteLine("</body>");
            fileOut.WriteLine(fileOut.NewLine);
            fileOut.WriteLine("</html>");

            fileOut.Close();

            //StatusMessageHandler.postStatusMessages(15);

            KosmorMapTool.warplanetList     = warplanetList;
            KosmorMapTool.planetList        = planetList;
            KosmorMapTool.neutralPlanetList = neutralPlanetList;
        }