/// <summary> /// This operation will ready the RedBlack dictionary to an array of strings, and the /// RedBlack wordsFound to an array of strings. This done so the serialization of the data /// objects become extremely easy for section 5 array encoding, and even easier for each data /// object's ultimate destination to the server side database. /// </summary> /// <param name="RedBlack_Dictionary">The RedBlack dictionary to convert.</param> /// <param name="puzzle">The char [,,] to convert.</param> /// <param name="RedBlack_wordsFound">The RedBlack wordsFound to convert.</param> /// <param name="solution">The solution object class reference.</param> private void SetDataForStorage( RedBlack RedBlack_Dictionary, char[,,] puzzle, RedBlack RedBlack_wordsFound, ref Solution solution ) { try { // Serialize the dictinary string path = @"\\" + System.Net.Dns.GetHostName() + @"\thepuzzler_3dstyle\ManageDB\dictionary.xml"; writer = new StreamWriter( path ); serializer = new XmlSerializer( typeof(string[]), "http://ns_DictionaryCreator" ); RedBlack_Dictionary.GetActualSize( RedBlack_Dictionary, ref index ); string [] dictionary = new string[index]; index = 0; VisitRedBlackTree( RedBlack_Dictionary, ref dictionary ); serializer.Serialize( writer.BaseStream, dictionary ); writer.Close(); reader = new StreamReader( path ); dictionaryXML = reader.ReadToEnd(); reader.Close(); // Serialize the puzzle path = @"\\" + System.Net.Dns.GetHostName() + @"\thepuzzler_3dstyle\ManageDB\puzzle.xml"; writer = new StreamWriter( path ); serializer = new XmlSerializer( typeof(char[][][]), "http://Puzzle_Creation" ); char[][][] jaggedPuzzle = ConvertTo3DJaggedArray( puzzle ); serializer.Serialize( writer.BaseStream, jaggedPuzzle ); writer.Close(); reader = new StreamReader( path ); puzzleXML = reader.ReadToEnd(); reader.Close(); // Serialize the wordsFound path = @"\\" + System.Net.Dns.GetHostName() + @"\thepuzzler_3dstyle\ManageDB\wordsFound.xml"; writer = new StreamWriter( path ); serializer = new XmlSerializer( typeof(string[]), "http://Puzzle_Solution" ); index = 0; RedBlack_wordsFound.GetActualSize(RedBlack_wordsFound, ref index); string [] wordsFound = new string[index]; index = 0; VisitRedBlackTree( RedBlack_wordsFound, ref wordsFound ); serializer.Serialize( writer.BaseStream, wordsFound ); writer.Close(); reader = new StreamReader( path ); wordsFoundXML = reader.ReadToEnd(); reader.Close(); } catch( Exception ex ) { new ManageDB_TestClass().HandleException( ref ex ); } finally { writer.Close(); reader.Close(); } }
/// <summary> /// The operation will (on the client side) call the StorePuzzlerRun() /// web service to store all of the current execution statics. /// </summary> /// <param name="solution">The Solution reference containing the dictionary, /// puzzle, and words found data to store in the data base.</param> /// <param name="statistics">The ManageStats reference containing the /// dictionary, puzzle, and solution execution times.</param> /// <returns>The success or failure message of the server side db insert operation.</returns> public string Call_StorePuzzlerRun( ref Solution solution, ref ManageStats statistics ) { SetDataForStorage( solution.Dictionary, solution.Puzzle, solution.WordsFound, ref solution ); dictionaryTime = statistics.DictionaryTime.Ticks; puzzleTime = statistics.PuzzleTime.Ticks; solutionTime = statistics.SolutionTime.Ticks; return dbinterface.StorePuzzlerRun( dictionaryXML, puzzleXML, wordsFoundXML, dictionaryTime, puzzleTime, solutionTime ); }
public void SetUp() { puzzleCreator = new PuzzleCreator(); solution = new Solution(); }
public void SetUpSingleThread() { solution = new Solution(); }
/// <summary> /// Default constructor for ManageStats. /// </summary> public ManageStats() { dictionaryTime = ""; puzzleTime = ""; solutionTime = ""; solution = new Solution(); dictionaryCreator = new DictionaryCreator(); puzzleCreator = new PuzzleCreator(); }