protected override void ShowValidationMessageAndNavigate(Response response)
        {
            this.Model.UIMessages.Clear();
            // put a null check for collection to casting issue
            var segmentValidationMessages = ExtractTextSegmentValidationMessages(response.Messages.IsNullOrEmpty() ? null : response.Messages.ToObservableCollection<MessageData>(), this.Model.DocumentDetails);
            ControllerArgs args = new ControllerArgs();
            // skip the message if only description editing is allowed
            if (segmentValidationMessages.Any() && this.Model.IsDataEntryAllowed)
            {
                args.SetProperty("WarningsExist", true);
                this.Model.UIMessages.AddRange(segmentValidationMessages);
                XIAPMessageBox.Show(StringResources.DocumentData_Validation,
                    StringResources.DocumentData_ValidationWarning,
                     XIAPMessageBox.Buttons.OkCancel,
                     (a, e) =>
                     {
                         if (e == ExitCode.OK)
                         {
                             Finish(args, this.Model.DocumentDetails);
                         }

                         return true;
                     });
            }
            else
            {
                args.SetProperty("WarningsExist", false);
                this.Finish(args, this.Model.DocumentDetails);
            }
        }
Exemple #2
0
        private void worker_ProgressChanged(object sender, ProgressChangedEventArgs e)
        {
            ControllerArgs args = (ControllerArgs)e.UserState;

            sw.Stop();
            if (args.current_trace == 1 | args.last || sw.ElapsedMilliseconds >= 30)
            {
                textBox_rtraces.Text     = args.current_trace.ToString();
                textBox_relapsed.Text    = args.elapsed.ToString("f3");
                textBox_rplaintext.Text  = Utils.byteArrayToString(args.plaintext);
                textBox_ranswer.Text     = Utils.byteArrayToString(args.answer);
                textBox_rciphertext.Text = Utils.byteArrayToString(args.ciphertext);
                textBox_rdifference.Text = Utils.byteArrayToString(args.difference);
                if (toolStripProgressBar_progress.ProgressBar != null)
                {
                    toolStripProgressBar_progress.Value = e.ProgressPercentage;
                }
                sw.Reset();

                textBox_rtraces.Update();
                textBox_relapsed.Update();
                textBox_rplaintext.Update();
                textBox_ranswer.Update();
                textBox_rciphertext.Update();
                textBox_rdifference.Update();
            }
            sw.Start();
        }
Exemple #3
0
        private void worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            if (e.Cancelled)
            {
                statusMessage("Cancelled.");
                toolStripProgressBar_progress.Value = 0;
            }
            else
            {
                ControllerArgs res = (ControllerArgs)e.Result;

                if (res.error)
                {
                    statusMessage("Error.");
                    toolStripProgressBar_progress.Value = 0;
                }
                else
                {
                    statusMessage("Completed.");
                }
            }

            if (!args.single)
            {
                rand.restartPlaintextPrng();
            }

            ctrl.Close();
            sw.Stop();
            state = appState.Idle;
            updateFormEnabling();
            toolStripProgressBar_progress.Style = ProgressBarStyle.Blocks;
        }
Exemple #4
0
        private JokeController PrepareStuff()
        {
            var args = new ControllerArgs(A.Fake <IConfiguration>())
            {
                BaseUrl = baseUrl
            };

            return(new JokeController(args));
        }
 private void Finish(ControllerArgs args, IDocumentDetails docData)
 {
     if (docData.CurrentStatusDescription != StaticValues.DocumentStatus.Generated.ToString())
     {
         this.Navigator.Finish(args);
     }
     else
     {
         this.Navigator.Finish(null);
     }
 }
        private void OnReasonCodeSelectComplete(Action callBack, ControllerArgs args)
        {
            if (args != null)
            {
                DeductibleReasonCodeArg reasonCodeArgs = (DeductibleReasonCodeArg)args;
                if (!string.IsNullOrEmpty(reasonCodeArgs.SelectedReasonCode))
                {
                    ClaimHeaderData claimHeaderData = (ClaimHeaderData)this.Model.ClaimHeaderDto.Data;
                    claimHeaderData.ClaimHeaderAnalysisCode08 = reasonCodeArgs.SelectedReasonCode;
                }
            }
            else
            {
                this.continueCoverageVerification = false;
            }

            if (callBack != null)
            {
                callBack();
            }
        }
        protected override void OnCVPolicySearchFinish(ControllerArgs args)
        {
            CoverageVerificationControllerArgs coverageVerificationArgs = args as CoverageVerificationControllerArgs;
            if (coverageVerificationArgs.PolicyReference == null && this._verifyCoverage == false)
            {
                coverageVerificationArgs.CoverageVerificationComplete = null;
            }

            base.OnCVPolicySearchFinish(coverageVerificationArgs);
        }
Exemple #8
0
        private void run(bool single)
        {
            args = new ControllerArgs();

            try
            {
                uint port = 0;
                if (String.Compare("USB", textBox_interface.Text.Substring(0, 3), true) == 0)
                {
                    if (!uint.TryParse(textBox_interface.Text.Substring(3), out port))
                    {
                        throw new Exception("Error: Invalid Interface.");
                    }
                }
                else
                {
                    throw new Exception("Error: Invalid Interface.");
                }

                ctrl.Open(port);
                ctrl.AddProgressChangedEventHandler(new ProgressChangedEventHandler(worker_ProgressChanged));
                ctrl.AddCompletedEventHandler(new RunWorkerCompletedEventHandler(worker_RunWorkerCompleted));

                args.single  = single;
                args.traces  = Convert.ToInt64(textBox_traces.Text);
                args.endless = checkBox_endless.Checked;
                if (!args.single)
                {
                    rand.restartPlaintextPrng();
                }

                sw.Start();
                statusMessage("Running...");

                toolStripProgressBar_progress.Value = 0;
                if (args.endless)
                {
                    toolStripProgressBar_progress.Style = ProgressBarStyle.Marquee;
                }
                else
                {
                    toolStripProgressBar_progress.Style = ProgressBarStyle.Blocks;
                }

                args.key              = Utils.stringToByteArray(textBox_key.Text);
                args.plaintext        = Utils.stringToByteArray(textBox_plaintext.Text);
                args.randomGeneration = checkBox_randomgeneration.Checked;
                args.wait             = Convert.ToInt32(textBox_wait.Text);
                args.continueIfError  = checkBox_continueiferror.Checked;
                args.check            = !checkBox_check.Checked;
                args.path             = textBox_path.Text;
                args.CurrentNum       = Convert.ToInt64(textBox_CurrentNum.Text);
                args.Algorithm        = comboBox1.SelectedItem.ToString();
                if (checkBox_rewrite.Checked)
                {
                    FileStream fs_ct = new FileStream("ciphertext.txt", FileMode.Create);
                    fs_ct.Close();
                    FileStream fs_key = new FileStream("key.txt", FileMode.Create);
                    fs_key.Close();
                    FileStream fs_pt = new FileStream("plaintext.txt", FileMode.Create);
                    fs_pt.Close();
                }

                if (Directory.Exists(args.path + "\\backup") == false)
                {
                    Directory.CreateDirectory(args.path + "\\backup");
                }

                //随机数生成,在每次重新run的时候重新随机获取种子
                Random  randc = new Random();
                RandGen randb = new RandGen(randc.Next(887667), randc.Next(434343));
                args.rand = randb;


                ctrl.Run(args);
            }
            catch (Exception ex)
            {
                statusMessage(ex.Message);
                toolStripProgressBar_progress.Value = 0;
                toolStripProgressBar_progress.Style = ProgressBarStyle.Blocks;
                state = appState.Idle;
                updateFormEnabling();
            }
        }