예제 #1
0
        private static async Task <IList <ContestResponse> > CreateAndSaveChallengesAsync(string json, ILogger logger)
        {
            logger.LogInformation($"C# CreateChallenges function processing async: {json}");

            ChallengeRequest request = ContestFactory.CreateChallengeRequest(json);

            BlobApi       blobApi = await BlobApi.Instance;
            CloudSkillApi cscApi  = await CloudSkillApi.Instance;

            Tuple <IList <ContestResponse>, string> tuple = await blobApi.GetAllContestTupleAsync(request.BaseInputs.Mstpid);

            if (tuple?.Item1 != null)
            {
                request.LearningPaths = RemoveDuplicateLearningPaths(request, tuple.Item1);
                await blobApi.DeleteBlobAsync(tuple.Item2);
            }

            List <ContestResponse> response = await cscApi.CreateChallengesAsyc(request);

            logger.LogInformation($"Created the Challenges. Saving response to blob");

            if (tuple?.Item1 != null)
            {
                foreach (ContestResponse contest in tuple.Item1)
                {
                    response.Add(contest);
                }
            }

            await WriteToBlobAsync(request.BaseInputs, response);

            logger.LogInformation($"C# CreateChallenges function processed");

            return(response);
        }
        private void buttonAddContest_Click(object sender, EventArgs e)
        {
            if (m_TabIndex < k_MaxNumberOfContests)
            {
                TabPageObserver tabPageContest = new TabPageObserver();

                if (m_TabIndex == 0)
                {
                    tabPageContest.Padding = new Padding(3);
                }

                FormAddContest newFormContest = new FormAddContest();
                newFormContest.ShowDialog();

                if (newFormContest.DialogResult == DialogResult.OK)
                {
                    IContest newContest = ContestFactory.CreateContest(
                        m_TabIndex + 1,
                        newFormContest.Status,
                        newFormContest.ImagePath,
                        newFormContest.NumberOfWinners,
                        newFormContest.LikeRequired,
                        newFormContest.CommentRequired);
                    m_ListOfContests.Add(newContest);

                    try
                    {
                        newContest.PostContestStatus();
                    }
                    catch (FacebookOAuthException)
                    {
                        MessageBox.Show("Failed to post status: No permissions.");
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }

                    tabPageContest.Location = new Point(104, 4);
                    tabPageContest.Name     = string.Format("tabPageContest{0}", m_TabIndex + 1);
                    tabPageContest.Size     = new Size(867, 616);
                    tabPageContest.TabIndex = m_TabIndex;
                    tabPageContest.Text     = string.Format("Contest {0}", m_TabIndex + 1);
                    tabPageContest.UseVisualStyleBackColor = true;
                    tabControlContest.Controls.Add(tabPageContest);
                    buildContest(tabPageContest);
                    m_TabIndex++;

                    m_ReportDeletedContestDelegate += tabPageContest.m_ReportDeletedContestObserver;
                }
            }
            else
            {
                MessageBox.Show("You have reached the maximum number of contests.");
            }
        }
예제 #3
0
        public async Task SendQueueMessageAyncTestAsync()
        {
            Configuration config = await TestHelper.GetConfigurationAsync();

            QueueApi queueApi = new QueueApi(config);

            SendReceipt sr = await queueApi.SendQueueMessageAync(ContestFactory.CreateChallengeRequestJson());

            Assert.IsNotNull(sr);
        }
예제 #4
0
        public async Task ReceiveQueueMessageAyncTestAsync()
        {
            Configuration config = await TestHelper.GetConfigurationAsync();

            QueueApi queueApi = new QueueApi(config);

            await queueApi.SendQueueMessageAync(ContestFactory.CreateChallengeRequestJson());

            Azure.Response <QueueMessage[]> response = await queueApi.ReceiveQueueMessageAync();

            Assert.IsNotNull(response);
        }
예제 #5
0
        public async Task CreateChallengesAsycTestAsync()
        {
            Configuration config = await TestHelper.GetConfigurationAsync();

            CloudSkillApi cscApi = new CloudSkillApi(config);

            string                 json               = ContestFactory.CreateChallengeRequestJson();
            ChallengeRequest       request            = ContestFactory.CreateChallengeRequest(json);
            List <ContestResponse> contestReponseList = await cscApi.CreateChallengesAsyc(request);

            Assert.IsTrue(contestReponseList.Count > 0);
        }