Example #1
0
        private void p0_btn_SendVerifyPin_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(p0_txtBox_VerifyPin.Text))
            {
                MessageBox.Show("Verification PIN could not be empty.", Config.TitleAppNameAndVersion, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                p0_txtBox_VerifyPin.Focus();
                return;
            }
            if (p0_txtBox_VerifyPin.Text.Length != Config.VerifyPinLength)
            {
                MessageBox.Show($"Verification PIN must have a length of {Config.VerifyPinLength} digits.", Config.TitleAppNameAndVersion, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                p0_txtBox_VerifyPin.Focus();
                return;
            }
            int intTest;

            if (!int.TryParse(p0_txtBox_VerifyPin.Text, out intTest))
            {
                MessageBox.Show($"Verification PIN must be a {Config.VerifyPinLength} digit number.", Config.TitleAppNameAndVersion, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                p0_txtBox_VerifyPin.Focus();
                return;
            }

            var verifyPinBody = new VerifyPinBody
            {
                pin = p0_txtBox_VerifyPin.Text
            };

            try
            {
                var pinVerificationResponse = new UweR70_PostCallWithNonEmptyBody().VerifyClientPIN(BaseData, verifyPinBody).Result;
                MessageBox.Show($"Verification succeeded:\r\nl{pinVerificationResponse.message}", Config.TitleAppNameAndVersion, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                var errorMessage = ex.Message;
                if (ex.InnerException != null && !string.IsNullOrEmpty(ex.InnerException.Message))
                {
                    errorMessage = ex.InnerException.Message;
                }
                MessageBox.Show(
                    "Verification error:\r\n" +
                    $"{errorMessage}\r\n" +
                    "\r\n" +
                    "Consider that the verification PIN expired already.\r\n" +
                    "Try to login again, wait for a new verification PIN\r\n" +
                    "and try again with the new PIN.",
                    Config.TitleAppNameAndVersion,
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
            }
        }
Example #2
0
        private void p0_btn_Start_Click(object sender, EventArgs e)
        {
            if (!IsDownloadRunning)
            {
                if (!AreAllNeededValuesGiven())
                {
                    return;
                }
                EmptyInfoText           = false;
                p0_txtBox_Info.Text     = p0_txtBox_VerifyPin.Text = string.Empty;
                p0_txtBox_Email.Enabled = p0_txtBox_Password.Enabled = p0_checkBox_AreYouInGermany.Enabled = p0_btn_SelectSavePath.Enabled = p0_btn_Start.Enabled
                                                                                                                                                 = p0_txtBox_VerifyPin.Enabled = p0_txtBox_VerifyPin.Enabled = false;
                p0_btn_Start.Text = "Running ...";

                DisableOrEnableallTabPagesExceptTheGiven(false, 0);
                ResetTabPage01Values();
                ResetTabPage02Values();
                ResetTabPage99Values();
                // ToDo: Do NOT remove this "ToDo" line and add here a "ResetTabPage_xx_Values();" method call in case a new tabPage is added to "tabControl0"!

                var taskA = Task.Factory.StartNew(() =>
                {
                    var mediaIdListBody = new MediaIdListBody
                    {
                        media_list = new List <long>()
                    };
                    BaseData = new InitAndDownload().Start(this, p0_txtBox_Email.Text, p0_txtBox_Password.Text, p0_txtBox_SaveDirectory.Text, p0_checkBox_AreYouInGermany.Checked, mediaIdListBody);
                    if (BaseData == null)
                    {
                        return;
                    }
                    if (mediaIdListBody != null && mediaIdListBody.media_list.Any())
                    {
                        var question = string.Empty;
                        if (mediaIdListBody.media_list.Count == 1)
                        {
                            question =
                                "One video was successfull downloaded.\r\n" +
                                "Should it be tried to delete the video on the server?";
                        }
                        else
                        {
                            question =
                                $"{mediaIdListBody.media_list.Count} videos were successfull downloaded.\r\n" +
                                "Should it be tried to delete all of them on the server?";
                        }
                        if (MessageBox.Show(question, Config.TitleAppNameAndVersion, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                        {
                            var message = new UweR70_PostCallWithNonEmptyBody().DeleteMediaCall(BaseData, mediaIdListBody).Result;
                            MessageBox.Show($"Deleted! Server response:\r\n{message.message}", Config.TitleAppNameAndVersion, MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                    if (!string.IsNullOrWhiteSpace(BaseData.StoragePathNetwork))
                    {
                        if (MessageBox.Show(
                                "Should the storage path be opened?",
                                Config.TitleAppNameAndVersion,
                                MessageBoxButtons.YesNo,
                                MessageBoxIcon.Question)
                            == DialogResult.Yes)
                        {
                            Process.Start(BaseData.StoragePathMain);
                        }
                    }
                }).ContinueWith(result =>
                {
                    // Controls are handled here to avoid a "cross-thread" error.
                    // And: Except PageTab it must also be worked out in case "StartAsyny(...)" returned "null" in error case!
                    if (BaseData != null)
                    {
                        DisableOrEnableallTabPagesExceptTheGiven(true, 0);
                    }
                    p0_btn_Start.Enabled = true;
                    p0_btn_Start.Text    = "Reset application";

                    p0_txtBox_VerifyPin.Enabled = p0_txtBox_VerifyPin.Enabled = true;
                    p0_txtBox_VerifyPin.Focus();

                    SetTabPage01Values(BaseData);
                    SetTabPage02Values(BaseData);
                    SetTabPage99Values(BaseData);
                    // ToDo: Do NOT remove this "ToDo" line and add here a "SetTabPage_xx_Values(BaseData);" method call in case a new tabPage is added to "tabControl0"!
                }, TaskScheduler.FromCurrentSynchronizationContext());
                // Do NOT add here something like
                //      var x = taskA.Result;
                // because this would block "taskA" ..
            }
            else
            {
                EmptyInfoText               = true;
                p0_txtBox_Info.Text         = HelpStart();
                p0_txtBox_Email.Enabled     = p0_txtBox_Password.Enabled = p0_checkBox_AreYouInGermany.Enabled = p0_btn_SelectSavePath.Enabled = p0_btn_Start.Enabled = true;
                p0_txtBox_VerifyPin.Text    = string.Empty;
                p0_txtBox_VerifyPin.Enabled = p0_txtBox_VerifyPin.Enabled = false;
                p0_btn_Start.Text           = "Start";

                DisableOrEnableallTabPagesExceptTheGiven(false, 0);
                ResetTabPage01Values();
                ResetTabPage02Values();
                ResetTabPage99Values();
                // ToDo: Do NOT remove this "ToDo" line and add here a "ResetTabPage_xx_Values();" method call in case a new tabPage is added to "tabControl0"!
            }
            IsDownloadRunning = !IsDownloadRunning;
        }