Beispiel #1
0
        /// <summary>
        /// Will push the boards to Azure Tables storage
        /// </summary>
        /// <param name="sol"></param>
        internal static void Publish(BoardSolution sol)
        {
            // Parse the connection string and return a reference to the storage account.
            string storageConfiguration = CloudConfigurationManager.GetSetting("StorageConnectionString");

            if (storageConfiguration == null)
            {
                storageConfiguration = Properties.Settings.Default.AzureStorageLocalConfig;
                // To debug with Fiddler
                // storageConfiguration = Properties.Settings.Default.AzureStorageLocalFiddler;
            }

            CloudStorageAccount storageAccount = CloudStorageAccount.Parse(storageConfiguration);

            // Create the table client.
            CloudTableClient tableClient = storageAccount.CreateCloudTableClient();

            // Retrieve a reference to the table.
            CloudTable table = tableClient.GetTableReference("boardsoltuion");

            // Create the table if it doesn't exist.
            table.CreateIfNotExists();

            // Create a new BoardSolutionTable.
            BoardSolutionTable solTable = new BoardSolutionTable(sol);

            // Create the TableOperation object that inserts the customer entity.
            TableOperation insertOperation = TableOperation.Insert(solTable);

            // Execute the insert operation.
            table.Execute(insertOperation);
        }
Beispiel #2
0
        public BoardSolutionTable(BoardSolution solution)
        {
            this.RowKey             = solution.GameBoardKey;
            this.PartitionKey       = (Math.Abs(solution.GameBoardKey.GetHashCode() % 1000)).ToString();
            this.BoardSize          = solution.SolvedBoard.Size;
            this.NumWordsInSolution = solution.SolutionWords.Count();

            string json = JsonConvert.SerializeObject(solution, Formatting.None);

            this.BoardSolutionJson = json;
        }
Beispiel #3
0
        public static BoardSolution Build_Solve_Publish(int dimension, string alphabetId, string dictionaryId)
        {
            BoardSolution sol = Build_Solve(4, alphabetId, dictionaryId);

            if (BoardEvaluator.EvaluateBoard(sol))
            {
                // Commenting publishing of the solution, we are not connected to Azure Storage now.
                // BoardPublisher.Publish(sol);
                return(sol);
            }
            else
            {
                return(null);
            }
        }
Beispiel #4
0
 // Boards with bad words should be discarded
 public static bool EvaluateBoard(BoardSolution solution)
 {
     return(true);
 }