Esempio n. 1
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            btnOK.Enabled = false;
            try
            {
                OptionsDataSet.Instance.Host         = txtServiceUrl.Text;
                OptionsDataSet.Instance.ConnTimeout  = DataHelper.ToInt(txtTimeout);
                OptionsDataSet.Instance.MaxConnCount = DataHelper.ToInt(txtMaxConnCount);
                // 测试连接
                ServiceAgent.TestConn();
                OptionsDataSet.Instance.Save();

                DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ExceptionParser.ParseError(ex));
                OptionsDataSet.Instance.Rollback();
                tabOrderManager.DealException(ex);
            }
            finally
            {
                btnOK.Enabled = true;
            }
        }
Esempio n. 2
0
        public void Should_parse_WebException()
        {
            var exception = new WebException("message");

            var result = ExceptionParser.ParseException(exception);

            Assert.IsNotNullOrEmpty(result);
        }
Esempio n. 3
0
        public void Should_parse_ParseException()
        {
            var exception = new ParseException("message", "content", null);

            var result = ExceptionParser.ParseException(exception);

            Assert.IsNotNullOrEmpty(result);
        }
Esempio n. 4
0
        public void GenerateMethodSignature_NullMethodReturnsNullSignature()
        {
            // Act
            var actSignature = ExceptionParser.GenerateMethodSignature(null);

            // Assert
            Assert.Null(actSignature);
        }
Esempio n. 5
0
        private void ReportErrorToUser(Exception exception)
        {
            var result = ExceptionParser.ParseException(exception);

            this.Error        = exception;
            this.ErrorMessage = result;
            this.ClipboardCommand.OnCanExecuteChanged();
        }
Esempio n. 6
0
        public void Parse_MessageIsSet_MessageIsReturned()
        {
            Exception ex = CreateException();

            var exceptionParser = new ExceptionParser();

            var parsedEx = exceptionParser.Parse(ex.ToString());

            Assert.AreEqual("my message", parsedEx.Message);
        }
Esempio n. 7
0
        public void Parse_SystemExceptionThrown_SystemExceptionReturned()
        {
            Exception ex = CreateException();

            var exceptionParser = new ExceptionParser();

            var parsedEx = exceptionParser.Parse(ex.ToString());

            Assert.AreEqual("System.Exception", parsedEx.Type);
        }
Esempio n. 8
0
        public void Should_Throw_InvalidOperationException_On_Null_Exception()
        {
            var exceptionParser = new ExceptionParser(new[] { new MockApiExceptionDescriptor() });

            ApiRequestException?apiRequestException = default;

            var exception = Assert.Throws <InvalidOperationException>(
                () =>
            {
                apiRequestException = exceptionParser.Parse(default !);
Esempio n. 9
0
        public void GenerateMethodSignature_GeneratesSignaturesCorrectly(string methodName, string expSignature)
        {
            // Arrange
            var method = typeof(ExceptionParserTests).GetMethod(methodName);

            // Act
            var actSignature = ExceptionParser.GenerateMethodSignature(method);

            // Assert
            Assert.Equal(expSignature, actSignature);
        }
        public void ParseException_MesgArgs()
        {
            ExceptionParser parser = new ExceptionParser("Name: {0}, Age: {1}", "Chris", 21);

            TryParseException(parser,
                              3,
                              "     ",
                              "",
                              "NAME  value",
                              "");
        }
Esempio n. 11
0
            public void Should_Return_True_For_Correct_Element()
            {
                // Given
                var parser = new ExceptionParser();
                var node   = @"<exception cref=""SparrowException"">Hello World</exception>".CreateXmlNode();

                // When
                var result = parser.CanParse(node);

                // Then
                Assert.True(result);
            }
Esempio n. 12
0
        public void GenerateExceptionInfo_NullIfNoStackTraceOnExceptionAndNoCallStack()
        {
            // Arrange
            var testConfig = new Configuration(TestApiKey);
            var exp        = new SystemException("System Error");

            // Act
            var actInfo = ExceptionParser.GenerateExceptionInfo(exp, null, testConfig);

            // Assert
            Assert.Null(actInfo);
        }
Esempio n. 13
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            string user     = txtUser.Text.Trim();
            string password = txtPassword.Text;

            if (string.IsNullOrEmpty(user))
            {
                MessageBox.Show("用户名不能为空!", "登陆失败");
                return;
            }

            if (cbOrgList.SelectedIndex < 0)
            {
                MessageBox.Show("组织不能为空!", "登陆失败");
                return;
            }

            btnLogin.Enabled = false;
            try
            {
                if (ServiceAgent.Agent.LoginValidate(user, txtPassword.Text))
                {
                    UserInfoDTO userInfoDTO = ServiceAgent.Agent.QueryUserInfo(user);

                    PDAContext.LoginUserID   = userInfoDTO.UserID;
                    PDAContext.LoginUserCode = userInfoDTO.UserCode;
                    PDAContext.LoginUserName = userInfoDTO.UserName;

                    PDAContext.LoginOrgID   = orgDict[cbOrgList.SelectedIndex].OrgID;
                    PDAContext.LoginOrgName = orgDict[cbOrgList.SelectedIndex].OrgName;

                    PDAContext.LoginDateTime = DateTime.Now;
                    // 保存登录信息
                    LoginInfoDataSet.Instance.Save(cbSavePassword.Checked, txtPassword.Text);

                    this.DialogResult = DialogResult.OK;
                }
                else
                {
                    MessageBox.Show("用户名密码不正确!", "登陆失败");
                    tabOrderManager.GoTo(txtPassword);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ExceptionParser.ParseError(ex));
            }
            finally
            {
                btnLogin.Enabled = true;
            }
        }
Esempio n. 14
0
        public void GenerateExceptionInfo_NullIfExceptionIsNull()
        {
            // Arrange
            var testConfig = new Configuration(TestApiKey);

            // Act
            var actInfoWithCall    = ExceptionParser.GenerateExceptionInfo(null, new StackTrace(), testConfig);
            var actInfoWithoutCall = ExceptionParser.GenerateExceptionInfo(null, null, testConfig);

            // Assert
            Assert.Null(actInfoWithCall);
            Assert.Null(actInfoWithoutCall);
        }
Esempio n. 15
0
            public void Should_Parse_Content_Recursivly()
            {
                // Given
                var commentParser = Substitute.For <ICommentParser>();
                var nodeParser    = new ExceptionParser();
                var node          = @"<exception cref=""SparrowException"">Hello World</exception>".CreateXmlNode();

                // When
                nodeParser.Parse(commentParser, node);

                // Then
                commentParser.Received(1).Parse(Arg.Any <XmlNode>());
            }
Esempio n. 16
0
            public void Should_Parse_Member()
            {
                // Given
                var commentParser = Substitute.For <ICommentParser>();
                var nodeParser    = new ExceptionParser();
                var node          = @"<exception cref=""SparrowException"">Hello World</exception>".CreateXmlNode();

                // When
                var result = nodeParser.Parse(commentParser, node);

                // Then
                Assert.Equal("SparrowException", result.Member);
            }
Esempio n. 17
0
        /// <summary>
        /// Copies the error report to clipboard.
        /// </summary>
        /// <param name="parameter">
        /// The exception.
        /// </param>
        protected override void InternalExecute(object parameter)
        {
            var error = parameter as Exception;

            var errorMessages = ExceptionParser.ParseException(error);

            var builder = new StringBuilder();

            builder.AppendLine("ATTENTION!");
            builder.AppendLine("Please fill information about your router and tomato firmware it uses");
            builder.AppendLine("You can also fill in your email address");
            builder.AppendLine(string.Empty);

            builder.AppendLine("Bandwidth Downloader UI Error report");
            builder.AppendLine("Generated: {0}".FormatWith(DateTime.Now));
            builder.AppendLine(string.Empty);

            builder.AppendLine("Contact information");
            builder.AppendLine("Name and/or email: YOUR EMAIL ADDRESS (OPTIONAL)");
            builder.AppendLine(string.Empty);

            builder.AppendLine("Hardware information");
            builder.AppendLine("Router: NAME AND VERSION OF YOUR ROUTER");
            builder.AppendLine("Firmware: NAME AND VERSIO OF THE TOMATO FIRMWARE YOUR ROUTER USES");
            builder.AppendLine(string.Empty);

            builder.AppendLine("Error messages:");
            builder.AppendLine(errorMessages);

            if (null != error)
            {
                builder.AppendLine("Stack trace:");
                builder.AppendLine(error.ToString());
            }

            var parseException = ExceptionParser.FindException <ParseException>(error);

            if (null != parseException)
            {
                builder.AppendLine("ParseException details");
                builder.Append(parseException.Details);
                builder.AppendLine(string.Empty);
                builder.AppendLine("Page that was parsed");
                builder.Append(parseException.Content);
            }

            builder.AppendLine("End of error report");

            this.clipboard.ReplaceWith(builder.ToString());
        }
        public void ParseException_JustMessage()
        {
            string          message = "See Spot run.";
            ExceptionParser parser  = new ExceptionParser(message);

            TryParseException(parser,
                              5,
                              "\n",
                              "     ",
                              "",
                              "> A comment line",
                              "NAME  value",
                              "");
        }
Esempio n. 19
0
        public void Parse_NormalException_StackTraceIsReturned()
        {
            Exception ex = CreateException();

            var exceptionParser = new ExceptionParser();

            var parsedEx = exceptionParser.Parse(ex.ToString());

            var expectedFirstStackTrace  = @"CatchPoint.Core.Tests.ExceptionParserTests.ThrowException() in C:\Users\Yaniv\source\repos\CatchPoint\CatchPoint.Core.Tests\ExceptionParserTests.cs:line";
            var expectedSecondStackTrace = @"CatchPoint.Core.Tests.ExceptionParserTests.CreateException() in C:\Users\Yaniv\source\repos\CatchPoint\CatchPoint.Core.Tests\ExceptionParserTests.cs:line";

            Assert.True(parsedEx.StackTrace.First().Contains(expectedFirstStackTrace));
            Assert.True(parsedEx.StackTrace.ElementAt(1).Contains(expectedSecondStackTrace));
        }
Esempio n. 20
0
        public async Task Should_Throw_UnauthorizedException()
        {
            const string       botToken  = "1234567:4TT8bAc8GHUspu3ERYn-KGcvsvGB9u_n4ddy";
            ITelegramBotClient botClient = new TelegramBotClient(botToken)
            {
                ExceptionParser = ExceptionParser.CreateDefault()
            };

            UnauthorizedException exception = await Assert.ThrowsAsync <UnauthorizedException>(
                async() => await botClient.GetMeAsync()
                );

            Assert.Equal(401, exception.ErrorCode);
            Assert.Equal("Unauthorized", exception.Message);
        }
Esempio n. 21
0
        public async Task Should_Fail_Test_Api_Token()
        {
            const string       botToken  = "0:1this_is_an-invalid-token_for_tests";
            ITelegramBotClient botClient = new TelegramBotClient(botToken)
            {
                ExceptionParser = ExceptionParser.CreateDefault()
            };

            NotFoundException exception = await Assert.ThrowsAsync <NotFoundException>(
                async() => await botClient.TestApiAsync()
                );

            Assert.Equal(404, exception.ErrorCode);
            Assert.Equal("Not Found", exception.Message);
        }
Esempio n. 22
0
        static bool CheckQAAC()
        {
            QAACEncoder e = new QAACEncoder("--check");

            try
            {
                e.start();
            } catch (OKETaskException ex)
            {
                ExceptionMsg msg = ExceptionParser.Parse(ex, null);
                MessageBox.Show(msg.errorMsg, ex.Message);
                return(false);
            }
            return(true);
        }
Esempio n. 23
0
        public JsonResult PosaljiStampuNaMail(string email, string subject, string text, string file, string replyTo)
        {
            var korisnik = RuntimeDataHelpers.GetRuntimeData(Request);
            var res      = new MyResponse();

            try
            {
                MailHelper.PosaljiEMailSaFajlom(email, subject, text, string.Format(@"{0}{1}", PutanjaAplikacije.Putanja, file), replyTo);
            }
            catch (Exception ex)
            {
                res.Greska = true;
                res.Poruka = ExceptionParser.Parsiraj(korisnik, ex);
            }
            return(Json(res, JsonRequestBehavior.DenyGet));
        }
Esempio n. 24
0
        public JsonResult PretraziNbsKlijente(string pib, long?maticniBroj, string naziv, string mesto, long?banka, long?brojRacuna, int?kontrolniBroj)
        {
            var res      = new MyResponse();
            var korisnik = RuntimeDataHelpers.GetRuntimeData(Request);

            try
            {
                res.Data = NbsData.PretraziNbsKlijente(maticniBroj, pib, banka, brojRacuna, kontrolniBroj, naziv, mesto);
            }
            catch (Exception ex)
            {
                res.Greska = true;
                res.Poruka = ExceptionParser.Parsiraj(korisnik, ex);
            }
            return(Json(res, JsonRequestBehavior.AllowGet));
        }
Esempio n. 25
0
        public JsonResult PrijaviGresku(string greska, string url, string slika)
        {
            var korisnik = RuntimeDataHelpers.GetRuntimeData(Request);
            var res      = new MyResponse();

            try
            {
                var msg = greska;

                try
                {
                    var urlSlike = slika.Split(',')[1];
                    var imgByte  = Convert.FromBase64String(urlSlike);
                    var guid     = Guid.NewGuid().ToString();
                    var fileName = Path.GetFileName(guid + ".jpg");

                    Directory.CreateDirectory(Server.MapPath("~/Content/DMS/GreskeslikeGresaka/"));
                    string putanjaFajla = Path.Combine(Server.MapPath("~/Content/DMS/GreskeslikeGresaka/"), fileName);

                    using (var file = new FileStream(putanjaFajla, FileMode.CreateNew))
                    {
                        file.Write(imgByte, 0, imgByte.Length);
                    }

                    var rek  = Request.UrlReferrer.AbsoluteUri;
                    var put2 = putanjaFajla.Replace(Path.Combine(Server.MapPath("~")), rek);
                    var bss  = "\\";
                    put2 = put2.Replace(bss, "/");
                    msg  = string.Format("{0}\n\nSlika: {1}", msg, put2);
                }
                catch (Exception e) { }

                var descBuilder = new StringBuilder(msg);
                descBuilder.AppendLine();

                var description = descBuilder.ToString();

                PredmetiData.PrijaviGresku(korisnik, description, url);//description je umesto greska
            }
            catch (Exception ex)
            {
                res.Greska = true;
                res.Poruka = ExceptionParser.Parsiraj(korisnik, ex);
            }

            return(Json(res, JsonRequestBehavior.DenyGet));
        }
Esempio n. 26
0
        /// <summary>
        /// 扫描条码
        /// </summary>
        private void ScanBarCode()
        {
            try
            {
                string barcode = txtBarCode.Text.Trim();
                if (string.IsNullOrEmpty(barcode))
                {
                    return;
                }

                if (docInfoArray == null || docInfoArray.Length == 0)
                {
                    BuildTabOrder(true);
                    throw new PDAException(txtDocNo, "请先录入出货计划单号或者扫描出货计划单条码");
                }

                BuildTabOrder(false);
                tabOrderManager.Reset();
                BarCodeInfoDTO dto = ServiceAgent.Agent.QueryBarCodeInfo(PDAContext.LoginOrgID, barcode);
                if (dto == null)
                {
                    throw new PDAException(txtBarCode, "没有找到该条形码的料品信息!");
                }

                ShipPlanDocDTO docDTO = MatchCompleteApplyDocDTO(dto);
                if (docDTO == null)
                {
                    throw new PDAException(txtBarCode, "该条码没有匹配到出货计划信息或者录入的条码超过该出货计划单!");
                }
                mainRow = dataSet.ShipBarCode.AddNewRow(dto, docDTO.ShipPlanID, docDTO.ShipPlanLineID);

                ShowInfo();
                // 显示行数
                ShowRowCount();
                // 焦点定位到最后一行
                this.dataGrid1.Focus();
                this.dataGrid1.CurrentRowIndex = this.dataSet.ShipBarCode.Count - 1;
                // 跳转到下一个控件
                tabOrderManager.Next();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ExceptionParser.ParseError(ex));
                tabOrderManager.DealException(ex);
            }
        }
Esempio n. 27
0
        public JsonResult VratiIstorijuPredmeta(long idPredmeta, bool?kretanje)
        {
            var korisnik = RuntimeDataHelpers.GetRuntimeData(Request);
            var res      = new MyResponse();

            try
            {
                res.Data = PredmetiData.VratiIstorijuPredmeta(korisnik, idPredmeta, kretanje);
            }
            catch (Exception ex)
            {
                res.Greska = true;
                res.Poruka = ExceptionParser.Parsiraj(korisnik, ex);
            }

            return(Json(res, JsonRequestBehavior.AllowGet));
        }
Esempio n. 28
0
        public JsonResult VratiSledeciSlobodanBrojPredmeta(short idOrgana, short idKlase)
        {
            var korisnik = RuntimeDataHelpers.GetRuntimeData(Request);
            var res      = new MyResponse();

            try
            {
                res.Data = PredmetiData.VratiSledeciSlobodanBrojPredmeta(korisnik, idOrgana, idKlase);
            }
            catch (Exception ex)
            {
                res.Greska = true;
                res.Poruka = ExceptionParser.Parsiraj(korisnik, ex);
            }

            return(Json(res, JsonRequestBehavior.AllowGet));
        }
Esempio n. 29
0
        public JsonResult AktivirajPredmet(long idPredmeta)
        {
            var korisnik = RuntimeDataHelpers.GetRuntimeData(Request);
            var res      = new MyResponse();

            try
            {
                PredmetiData.AktivirajPredmet(korisnik, idPredmeta);
            }
            catch (Exception ex)
            {
                res.Greska = true;
                res.Poruka = ExceptionParser.Parsiraj(korisnik, ex);
            }

            return(Json(res, JsonRequestBehavior.DenyGet));
        }
Esempio n. 30
0
        public JsonResult PromeniLozinku(string staraSifra, string novaSifra)
        {
            var korisnik = RuntimeDataHelpers.GetRuntimeData(Request);
            var res      = new MyResponse();

            try
            {
                LogovanjeData.PromeniLozinkuKorisnika(korisnik, Konverzija.KonvertujULatinicu(staraSifra), Konverzija.KonvertujULatinicu(novaSifra));
            }
            catch (Exception ex)
            {
                res.Greska = true;
                res.Poruka = ExceptionParser.Parsiraj(korisnik, ex);
            }

            return(Json(res, JsonRequestBehavior.DenyGet));
        }