示例#1
0
        //upload current automaton in GUI to data
        private void button1_Click(object sender, EventArgs e)
        {
            textBox12.Text = string.Empty;
            textBox11.Text = string.Empty;
            textBox17.Text = string.Empty;
            textBox19.Text = string.Empty;
            Automaton tmpAutomaton = new Automaton();

            tmpAutomaton = Data.userInput(textBox8.Text, textBox9.Text, textBox15.Text, textBox16.Text, textBox10.Text, textBox11.Text);
            bool flag = true;

            if (!ErrorCheck.checkInitial(tmpAutomaton))
            {
                textBox19.AppendText("Initial state not found within automaton states");
                flag = false;
            }
            if (!ErrorCheck.checkAccepting(tmpAutomaton))
            {
                textBox19.AppendText("Accepting state not found within automaton states");
                flag = false;
            }
            if (!ErrorCheck.checkTransitions(tmpAutomaton))
            {
                textBox19.AppendText("Transition element not found within automaton states or alphabet");
                flag = false;
            }

            if (flag)
            {
                finiteAutomaton = tmpAutomaton;
            }
        }
示例#2
0
        public IActionResult Update(InvoiceViewModel invVM)
        {
            // Check eerst de standaard fouten:
            // Standaard (data-annotation) fouten worden bij het veld zelf getoond
            if (!ModelState.IsValid)
            {
                return(View(invVM));
            }

            // Check hier de velden op complexere correcte invoer
            // Stop met valideren bij de eerste gevonden fout
            // Deze complexere fouten worden in de message-box getoond

            string errMsg = ErrorCheck.CheckForErrors(invVM);

            if (errMsg != null) // Specifieke fout gevonden
            {
                ModelState.AddModelError(string.Empty, errMsg);
                return(View(invVM));
            }

            // converteer InvVM naar InvoiceViewModel via extension method
            var invoiceDb     = invVM.ToInvoice();
            var invLineListDb = invVM.ToInvoiceLineList();

            _invoiceManager.UpdInvoiceAndLines(invoiceDb, invLineListDb);

            return(RedirectToAction("Index",
                                    new
            {
                doctorId = invVM.Invoice.DoctorId,
                clientId = invVM.Invoice.ClientId
            }));
        }
示例#3
0
        /// <summary>Creates exception by wrapping <paramref name="errorCode"/> and with message corresponding to code.</summary>
        /// <param name="errorCheck">Type of check was done.</param> <param name="errorCode">Error code to wrap, <see cref="Error"/> for codes defined.</param>
        /// <param name="arg0">(optional) Arguments for formatted message.</param> <param name="arg1"></param> <param name="arg2"></param> <param name="arg3"></param>
        /// <param name="inner">(optional) Inner exception to wrap.</param>
        /// <returns>Create exception object.</returns>
        public new static AttributedModelException Of(ErrorCheck errorCheck, int errorCode,
                                                      object arg0, object arg1 = null, object arg2 = null, object arg3 = null,
                                                      Exception inner          = null)
        {
            var message = string.Format(MefAttributedModel.Error.GetMessage(errorCode), Print(arg0), Print(arg1), Print(arg2), Print(arg3));

            return(inner == null
                ? new AttributedModelException(errorCode, message)
                : new AttributedModelException(errorCode, message, inner));
        }
示例#4
0
 public static void CheckErrorLogs(List<LogInfo> logs, ErrorCheck check)
 {
     switch (check)
     {
         case ErrorCheck.Success:
             foreach (LogInfo log in logs)
             {
                 Assert.IsTrue(log.State != LogState.Error);
                 Assert.IsTrue(log.State != LogState.CriticalError);
                 Assert.IsTrue(log.State != LogState.Warning);
             }
             break;
         case ErrorCheck.Warning:
             {
                 bool result = false;
                 foreach (LogInfo log in logs)
                 {
                     Assert.IsTrue(log.State != LogState.Error);
                     Assert.IsTrue(log.State != LogState.CriticalError);
                     if (log.State == LogState.Warning)
                         result = true;
                 }
                 Assert.IsTrue(result);
             }
             break;
         case ErrorCheck.Overwrite:
             {
                 bool result = false;
                 foreach (LogInfo log in logs)
                 {
                     Assert.IsTrue(log.State != LogState.Error);
                     Assert.IsTrue(log.State != LogState.CriticalError);
                     if (log.State == LogState.Overwrite)
                         result = true;
                 }
                 Assert.IsTrue(result);
             }
             break;
         case ErrorCheck.Error:
             {
                 bool result = false;
                 foreach (LogInfo log in logs)
                 {
                     Assert.IsTrue(log.State != LogState.CriticalError);
                     if (log.State == LogState.Error)
                         result = true;
                 }
                 Assert.IsTrue(result);
             }
             break;
         default:
             Assert.Fail();
             break;
     }
 }
        protected override async Task <ErrorCheck> HasErrors(
            PublishedProvider publishedProvider,
            PublishedProvidersContext publishedProvidersContext)
        {
            Guard.ArgumentNotNull(publishedProvidersContext, nameof(publishedProvidersContext));

            ErrorCheck errorCheck = new ErrorCheck();

            // if there is no released version then we don't need to do the check
            if (publishedProvider.Released == null)
            {
                return(errorCheck);
            }

            IEnumerable <Common.ApiClient.Providers.Models.Provider> apiClientProviders =
                _mapper.Map <IEnumerable <Common.ApiClient.Providers.Models.Provider> >(publishedProvidersContext.ScopedProviders);
示例#6
0
        /// <summary>
        /// Check to see if all of the tokens in the equation are in a proper order
        /// </summary>
        private void ProperOrder()
        {
            //variables to count the amount of right and left Parenthesis
            int[] ParenthesisCount = new int[] { 0, 0 };

            //delegate to check for particular errors
            ErrorCheck currentFunction = StartingTokenRule;

            foreach (string token in equation)
            {
                currentFunction(token);
                IncreaseParenthesisCount(token, ParenthesisCount);
                RightParenthesisRule(ParenthesisCount);
                currentFunction = SwitchFunction(token);
            }
            BalanceParenthesisRule(ParenthesisCount);
            EndingTokenRule(equation[equation.Length - 1]);
        }
示例#7
0
        public IActionResult Create(InvoiceViewModel invVM)
        {
            if (!ModelState.IsValid)
            {
                // Geef de ViewModel terug:

                // Het viewmodel moet altijd in de return, ook al doet het scherm er niets mee
                // Het scherm verwacht namelijk altijd deze VM, zowel bij de Get als bij de Post
                return(View(invVM));
            }

            // Check hier de velden op correcte invoer (complexer)
            // Stop met valideren bij de eerste gevonden fout

            // Opmerking: als je spaties invult in een Line, wordt dit
            // als een NULL string terug aan deze POST ACTION Method teruggegeven
            string errMsg = ErrorCheck.CheckForErrors(invVM);

            if (errMsg != null) // Specifieke fout gevonden
            {
                ModelState.AddModelError(string.Empty, errMsg);

                // VM moet altijd in de return, ook al doet het scherm er niets mee
                // Het scherm verwacht altijd deze VM, zowel bij de Get als bij de Create
                return(View(invVM));
            }

            var invoiceDb         = invVM.ToInvoice();
            var invoiceLineListDb = invVM.ToInvoiceLineList();

            // Genereer nieuw invoicenummer uit de stamtabel met reeksen
            invoiceDb.InvoiceNumber = _invoiceManager.RtvNewInvoiceNumber();
            _invoiceManager.AddInvoiceAndLines(invoiceDb, invoiceLineListDb);

            return(RedirectToAction("Index",
                                    new
            {
                doctorId = invVM.Invoice.DoctorId,
                clientId = invVM.Invoice.ClientId
            }));
        }
        public IActionResult  Create(PrescrWith5LinesViewModel pW5LinesVM)
        {
            // Onderstaande werkt niet:


            if (!ModelState.IsValid)
            {
                pW5LinesVM.Prescription.PrescriptionDescr = "Descr is CHANGED";
                return(View(pW5LinesVM));
            }

            // Check hier de velden op correcte invoer (complexer)
            // Stop met valideren bij de eerste gevonden fout

            // Opmerking: als je spaties invult in een Line, wordt dit
            // als een NULL string terug aan deze POST ACTION Method teruggegeven
            string errMsg = ErrorCheck.CheckForErrors(pW5LinesVM);

            if (errMsg != null) // Specifieke fout gevonden
            {
                ModelState.AddModelError(string.Empty, errMsg);

                // VM moet altijd in de return, ook al doet het scherm er niets mee
                // Het scherm verwacht altijd deze VM, zowel bij de Get als bij de Create
                return(View(pW5LinesVM));
            }

            var prescr         = pW5LinesVM.ToPrescr();
            var prescrLineList = pW5LinesVM.ToPrescrLineList();

            _prescrManager.AddPrescrAndLines(prescr, prescrLineList);

            return(RedirectToAction("Index",
                                    new
            {
                doctorId = pW5LinesVM.Prescription.DoctorId,
                clientId = pW5LinesVM.Prescription.ClientId
            }));
        }
示例#9
0
        public static EngineState Eval(EngineState s, string rawCode, CodeType type, ErrorCheck check, out CodeCommand cmd)
        {
            // Create CodeCommand
            SectionAddress addr = EngineTests.DummySectionAddress();
            cmd = CodeParser.ParseStatement(rawCode, addr);
            if (cmd.Type == CodeType.Error)
            {
                Console.WriteLine((cmd.Info as CodeInfo_Error).ErrorMessage);
                Assert.IsTrue(check == ErrorCheck.ParserError);
                return s;
            }
            Assert.IsTrue(cmd.Type == type);

            // Run CodeCommand
            List<LogInfo> logs = Engine.ExecuteCommand(s, cmd);

            // Assert
            EngineTests.CheckErrorLogs(logs, check);

            // Return EngineState
            return s;
        }
示例#10
0
        private static void WriteTemplate(
            EngineState s, CodeType type,
            string rawCode, string testFile, string sampleStr, string expectStr,
            ErrorCheck check = ErrorCheck.Success)
        {
            if (File.Exists(testFile))
            {
                File.Delete(testFile);
            }
            try
            {
                File.Create(testFile).Close();

                EncodingHelper.WriteTextBom(testFile, Encoding.UTF8);
                using (StreamWriter w = new StreamWriter(testFile, true, Encoding.UTF8))
                {
                    w.Write(sampleStr);
                }

                EngineTests.Eval(s, rawCode, type, check);
                if (check == ErrorCheck.Success || check == ErrorCheck.Warning)
                {
                    string resultStr;
                    using (StreamReader r = new StreamReader(testFile, Encoding.UTF8))
                    {
                        resultStr = r.ReadToEnd();
                    }

                    Assert.IsTrue(resultStr.Equals(expectStr, StringComparison.Ordinal));
                }
            }
            finally
            {
                if (File.Exists(testFile))
                {
                    File.Delete(testFile);
                }
            }
        }