////////////////////////////////////////////////////////////// //defines the filename based on wpt attribute & opens the file // if new ////////////////////////////////////////////////////////////// private static System.IO.StreamWriter WptCsv(Framework.Data.Geocache gc, Framework.Data.Waypoint wpt) { string csvName=null; string postFix=""; switch (wpt.WPType.ID) { case 217: csvName="Parking_Area";break; case 218: csvName="Question_to_Answer";break; case 219: csvName="Stages_of_a_Multicache";break; case 220: csvName="Final_Location";break; case 221: csvName="Trailhead";break; case 452: csvName="Reference_Point";break; default: csvName=wpt.WPType.Name.Replace(" ","_");break; } if (gc.Found) {postFix="_Found";} if (!gc.Available || gc.Archived) {postFix="_Disabled";} csvName=csvName+postFix; if (!sd.ContainsKey(csvName)) { //new -> open File System.IO.StreamWriter cs=null; string csvPath=Path.GetDirectoryName(csvFile)+Path.DirectorySeparatorChar+csvName+".csv"; cs=new System.IO.StreamWriter(csvPath, false, Encoding.GetEncoding(1250)); sd.Add(csvName,cs); //create wpt icon byte[] binaryData; binaryData = System.Convert.FromBase64String(GetBmpData(csvName)); System.IO.FileStream bmpFile = new System.IO.FileStream( Path.GetDirectoryName(csvFile)+Path.DirectorySeparatorChar+csvName+".bmp", System.IO.FileMode.Create,System.IO.FileAccess.Write); bmpFile.Write(binaryData, 0, binaryData.Length); bmpFile.Close(); } return sd[csvName]; }
////////////////////////////////////////////////////////////// //defines the filename based on gc attribute & opens the file if new ////////////////////////////////////////////////////////////// private static System.IO.StreamWriter CacheCsv(Framework.Data.Geocache gc) { string csvName=null; string postFix=""; switch (gc.GeocacheType.ID) { case 2: csvName="Traditional"; if (gc.Container.ID==2) { csvName="Micro"; //ShowMicroTradis } break; case 3: csvName="Multi"; if (gc.CustomCoords || (gc.CustomLat != null && gc.CustomLon != null)) { postFix="_Solved"; } break; case 4: csvName="Virtual";break; case 5: csvName="Letterbox";break; case 6: csvName="Event";break; case 8: csvName="Mystery"; if (gc.CustomCoords || (gc.CustomLat != null && gc.CustomLon != null)) { postFix="_Solved"; } break;// case 9: csvName="Project_APE";break; case 11: csvName="Webcam";break; case 12: csvName="Locationless";break; case 13: csvName="CITO";break; case 27: csvName="Benchmark";break; //hopefully case 137: csvName="Earth";break; case 453: csvName="Mega_Event";break; case 605: csvName="Course";break; //Geocache Course case 1304: csvName="Maze";break; //GPS Adventures Exhibit case 1858: csvName="Whereigo"; if (gc.CustomCoords || (gc.CustomLat != null && gc.CustomLon != null)) { postFix="_Solved"; } break; case 3653: csvName="Lost_and_Found_Event";break; case 3773: csvName="Groundspeak_HQ";break; case 3774: csvName="Groundspeak_Lost_and_Found";break; case 4738: csvName="Groundspeak_Block_Party";break; default: csvName=gc.GeocacheType.Name.Replace(" ","_");break; } if (gc.Found) { csvName="Found"; if (gc.CustomCoords || (gc.CustomLat != null && gc.CustomLon != null)) { postFix="_Solved"; } } if (!gc.Available || gc.Archived) { postFix="_Disabled";//overwrites "_Solved" if any } csvName=csvName+postFix; if (!sd.ContainsKey(csvName)) { //new -> open File System.IO.StreamWriter cs=null; // string csvPath=Path.GetDirectoryName(csvFile)+Path.DirectorySeparatorChar+csvName+".csv"; cs=new System.IO.StreamWriter(csvPath, false, Encoding.GetEncoding(1250)); //1250 = Write as ANSI sd.Add(csvName,cs); //create gc icon byte[] binaryData; binaryData = System.Convert.FromBase64String(GetBmpData(csvName)); System.IO.FileStream bmpFile = new System.IO.FileStream( Path.GetDirectoryName(csvFile)+Path.DirectorySeparatorChar+csvName+".bmp", System.IO.FileMode.Create,System.IO.FileAccess.Write); bmpFile.Write(binaryData, 0, binaryData.Length); bmpFile.Close(); } return sd[csvName]; }