public bool UpdateReport(Report report, string Email, string MD5PassHash) { try { DataValidator.CheckAuthorization(Email, MD5PassHash, this.DBManager); } catch (UserNotAuthorizedException e) { return(false); } try { return(DBManager.UpdateReport(report)); } catch (FaultException <DatabaseFault> df) { throw new FaultException <ManagerFault>(new ManagerFault(df.ToString())); } }
public static bool Delete(string surveyId) { bool flag = false; if (!string.IsNullOrEmpty(surveyId) && DataValidator.IsValidId(surveyId)) { flag = dal.Delete(surveyId); if (!flag) { return(flag); } SurveyVote.Delete(surveyId); foreach (string str in surveyId.Split(new char[] { ',' })) { SurveyRecord.DeleteTable(DataConverter.CLng(str)); } } return(flag); }
public async Task DataValidatorTest() { DataValidator <GetUserContactsRequestDto> validator = new DataValidator <GetUserContactsRequestDto>(); GetUserContactsRequestDto message = new GetUserContactsRequestDto() { UserID = -2 }; bool result = await validator.IsValid(message); result.Should().BeFalse(); message.UserID = 2; result = await validator.IsValid(message); result.Should().BeTrue(); }
private void txtVATRate_Leave(object sender, EventArgs e) { TextBox txtTextbox = sender as TextBox; if (txtTextbox.Text != "") { if (DataValidator.IsNumeric(txtTextbox.Text)) { txtTextbox.Text = Convert.ToDecimal(txtTextbox.Text).ToString("#0.00"); // Set Decimal Value after textbox's Leave Event lblErrorMessage.Text = "No error"; int t = txtTextbox.TextLength; if (t <= txtTextbox.MaxLength) { btnSaveExit.Enabled = true; lblErrorMessage.Text = "No error"; } else { lblErrorMessage.Text = DataValidator.lblFormatMessage + "99.99"; txtTextbox.Focus(); btnSaveExit.Enabled = false; } } else { txtTextbox.Text = "0.00"; btnSaveExit.Enabled = true; } } else { txtTextbox.Text = "0.00"; btnSaveExit.Enabled = true; } if (Convert.ToDecimal(txtVATRate.Text) > 0 || Convert.ToDecimal(txtAVATRate.Text) > 0) { txtCSTRate.Text = "0.00"; } CalculateNetAmount(); }
public User GetUserByEmail(string SearchedEmail, string Email, string MD5PassHash) { try { DataValidator.CheckAuthorization(Email, MD5PassHash, this.DBManager); } catch (UserNotAuthorizedException e) { return(null); } try { return(DBManager.GetUserByEmail(SearchedEmail)); } catch (FaultException <DatabaseFault> df) { throw new FaultException <ManagerFault>(new ManagerFault(df.ToString())); } }
public bool DeleteService(int ID, string Email, string MD5PassHash) { try { DataValidator.CheckAuthorization(Email, MD5PassHash, this.DBManager); } catch (UserNotAuthorizedException e) { return(false); } try { return(DBManager.DeleteService(ID)); } catch (FaultException <DatabaseFault> df) { throw new FaultException <ManagerFault>(new ManagerFault(df.ToString())); } }
public void ValidateReturnValueTest() { var value = default(User); DataValidator.ValidateReturnValue(value); value = new User(); Assert.Throws <ValidationException>(() => DataValidator.ValidateReturnValue(value)); value = new User { Account = "123" }; DataValidator.ValidateReturnValue(value); value = new User { Account = "123456" }; Assert.Throws <ValidationException>(() => DataValidator.ValidateReturnValue(value)); }
private static TradeInfo ReadTradeInfo(EntryObject o) { if (!DataValidator.IsValidTradeReference(o.PortfolioId)) { throw new InvalidDataException($"The CRIF file contains a {o.RiskType} entry with an invalid portfolio identifier."); } if (!DataValidator.IsValidTradeReference(o.TradeId)) { throw new InvalidDataException($"The CRIF file contains a {o.RiskType} entry with an invalid trade identifier."); } if (!DateTime.TryParseExact(o.EndDate, "yyyy-MM-dd", CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime endDate)) { throw new InvalidDataException($"The CRIF file contains a {o.RiskType} entry with an invalid EndDate property."); } return(TradeInfo.OfUnchecked(o.PortfolioId, o.TradeId, endDate)); }
private void btn_OK_Click(object sender, EventArgs e) { // Get all information in textbox string deviceName = textBox1.Text; string deviceIP = textBox2.Text; string deviceUser = textBox3.Text; string devicePwd = textBox4.Text; if (deviceName != "" && DataValidator.IsIP(deviceIP) && devicePwd != "" && deviceUser != "") { Device updatingDevice = new Device(deviceName, deviceIP, deviceUser, devicePwd); XMLOperator.UpdateDevice(updatingDevice); } else { MessageBox.Show("输入信息不合法", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void btnSaveExit_Click(object sender, EventArgs e) { try { if (DataValidator.IsValid(this.grpData)) { DataRow dr; dr = _dtDetail.NewRow(); dr["ItemID"] = _ItemID; dr["ItemName"] = txtItemName.Text; dr["UOM"] = txtUOM.Text; dr["Qty"] = Convert.ToDecimal(txtQty.Text); dr["Rate"] = Convert.ToDecimal(txtRate.Text); dr["TotalAmount"] = Convert.ToDecimal(txtAmount.Text);; dr["TaxClassID"] = Convert.ToInt64(cmbTaxClass.SelectedValue); dr["ServiceRate"] = Convert.ToDecimal(txtServiceTax.Text); dr["ServiceAmount"] = Convert.ToDecimal(txtServiceAmt.Text); dr["ExciseRate"] = Convert.ToDecimal(txtExciseRate.Text); dr["ExciseAmount"] = Convert.ToDecimal(txtExciseAmt.Text); dr["ECessRate"] = Convert.ToDecimal(txtEduCessRate.Text); dr["ECessAmount"] = Convert.ToDecimal(txtEduCessAmt.Text); dr["HECessRate"] = Convert.ToDecimal(txtHEduCessRate.Text); dr["HECessAmount"] = Convert.ToDecimal(txtHEduCessAmt.Text); dr["AmountAfterExcise"] = Convert.ToDecimal(txtAmtwithExcise.Text); dr["CSTRate"] = Convert.ToDecimal(txtCSTRate.Text); dr["CSTAmount"] = Convert.ToDecimal(txtCSTAmt.Text); dr["VATRate"] = Convert.ToDecimal(txtVATRate.Text); dr["VATAmount"] = Convert.ToDecimal(txtVATAmt.Text); dr["AVATRate"] = Convert.ToDecimal(txtAVATRate.Text); dr["AVATAmount"] = Convert.ToDecimal(txtAVATAmt.Text); dr["NetAmount"] = Convert.ToDecimal(txtNetAmount.Text); dr["ItemDesc"] = txtItemDesc.Text; _dtDetail.Rows.Add(dr); this.Dispose(); } } catch (Exception exc) { Utill.Common.ExceptionLogger.writeException("Sales Invoice", exc.StackTrace); MessageBox.Show(Utill.Common.CommonMessage.ExceptionMesg, "Exception"); } }
/// <summary>Initializes and returns a new instance using the specified parameters.</summary> /// <param name="qualifier">The <see cref="T:System.String"/> representing the qualifier of the entity.</param> /// <param name="factor">The <see cref="T:System.Decimal"/> representing the parameter of the entity.</param> /// <param name="regulationsInfo">The <see cref="T:InitialMargin.Core.RegulationsInfo"/> defining collect and post regulations of the entity.</param> /// <returns>A new instance of <see cref="T:InitialMargin.Model.AddOnNotionalFactor"/> initialized with the specified parameters.</returns> /// <exception cref="T:System.ArgumentException">Thrown when <paramref name="qualifier">qualifier</paramref> is invalid (see <see cref="M:InitialMargin.Core.DataValidator.IsValidNotionalQualifier(System.String)"/>) or when <paramref name="factor">factor</paramref> does not belong to the interval <c>(0,1]</c>.</exception> /// <exception cref="T:System.ArgumentNullException">Thrown when <paramref name="regulationsInfo">regulationsInfo</paramref> is <c>null</c>.</exception> public static AddOnNotionalFactor Of(String qualifier, Decimal factor, RegulationsInfo regulationsInfo) { if (!DataValidator.IsValidNotionalQualifier(qualifier)) { throw new ArgumentException("Invalid qualifier specified.", nameof(qualifier)); } if ((factor <= 0m) || (factor > 1m)) { throw new ArgumentException("Invalid factor specified.", nameof(factor)); } if (regulationsInfo == null) { throw new ArgumentNullException(nameof(regulationsInfo)); } return(new AddOnNotionalFactor(qualifier, factor, regulationsInfo)); }
public void TestProcessThemeNull() { var validator = new DataValidator(); validator.SensorTypeFilter = new SensorType[] { SensorType.Data, SensorType.Entity, SensorType.Virtual }; var source = new List <SensorAcqResult>(); source.Add( new SensorAcqResult { AcqTime = DateTime.Now, ErrorCode = 0, Sensor = new Sensor { SensorID = 990 }, Data = new MockSensor(null, null, null), }); validator.ProcessResult(source); }
/// <summary>Initializes and returns a new instance using the specified parameters.</summary> /// <param name="qualifier">The <see cref="T:System.String"/> representing the qualifier of the entity.</param> /// <param name="amount">The <see cref="T:InitialMargin.Core.Amount"/> of the entity.</param> /// <param name="regulationsInfo">The <see cref="T:InitialMargin.Core.RegulationsInfo"/> defining collect and post regulations of the entity.</param> /// <param name="tradeInfo">The <see cref="T:InitialMargin.Core.TradeInfo"/> defining the underlying trade of the entity.</param> /// <returns>A new instance of <see cref="T:InitialMargin.Model.AddOnNotional"/> initialized with the specified parameters.</returns> /// <exception cref="T:System.ArgumentException">Thrown when <paramref name="qualifier">qualifier</paramref> is invalid. See <see cref="M:InitialMargin.Core.DataValidator.IsValidNotionalQualifier(System.String)"/>.</exception> /// <exception cref="T:System.ArgumentNullException">Thrown when <paramref name="regulationsInfo">regulationsInfo</paramref> is <c>null</c> or when <paramref name="tradeInfo">tradeInfo</paramref> is <c>null</c>.</exception> public static AddOnNotional Of(String qualifier, Amount amount, RegulationsInfo regulationsInfo, TradeInfo tradeInfo) { if (!DataValidator.IsValidNotionalQualifier(qualifier)) { throw new ArgumentException("Invalid qualifier specified.", nameof(qualifier)); } if (regulationsInfo == null) { throw new ArgumentNullException(nameof(regulationsInfo)); } if (tradeInfo == null) { throw new ArgumentNullException(nameof(tradeInfo)); } return(new AddOnNotional(qualifier, amount, regulationsInfo, tradeInfo)); }
static void Main(string[] args) { try { // Variables DataConverter dataConverter = new DataConverter(); DataValidator dataValidator = new DataValidator(dataConverter); EnrollmentFileManager fileManager = new EnrollmentFileManager(dataValidator, dataConverter); string inbox = ConfigurationManager.AppSettings["Inbox"].ToString(); var listOfEnrollments = fileManager.ProcessEnrollmentData(inbox); // If list of enrollment information is not null and more than 0, then proceed to printing the results if (listOfEnrollments != null && listOfEnrollments.Count > 0) { // Header was not required, but could be a nice addition. Console.WriteLine($"Status | First Name | Last Name | DOB | Plan Type | Effective Date | \n"); foreach (var enrollmentInfo in listOfEnrollments) { // Print enrollment records to the console. EnrollmentFileManager.PrintEnrollmentRecordsToConsole(enrollmentInfo); } } else { // Print this if there are 0 records in the file. Console.WriteLine("No data exist!"); } EnrollmentFileManager.CloseApplication(); } catch (Exception) { // We could pass in a exception's variable (ex) to print out what the exception is to the console. Console.WriteLine($"A record in the file failed validation. Processing has stopped."); Console.ReadKey(); } }
private void btnApply_Click(object sender, EventArgs e) { try { StrFilter = ""; if (txtFromCode.Text.Trim() != "") { StrFilter = StrFilter + " PurchaseCode Like '%" + PrepareFilterString(txtFromCode.Text.Trim()) + "%' And "; } if (DataValidator.IsDate(txtFromDate.Text.Trim())) { StrFilter = StrFilter + " PurchaseDate >= '" + txtFromDate.Text.Trim() + "' And "; } if (DataValidator.IsDate(txtTodate.Text.Trim())) { StrFilter = StrFilter + " PurchaseDate <= '" + txtTodate.Text.Trim() + "' And "; } if (txtCompany.Text.Trim() != "") { StrFilter = StrFilter + " VendorName Like '%" + PrepareFilterString(txtCompany.Text.Trim()) + "%' And "; } if (txtSrNo.Text.Trim() != "") { StrFilter = StrFilter + " SrNo Like '%" + PrepareFilterString(txtSrNo.Text.Trim()) + "%' And "; } if (StrFilter != "") { StrFilter = StrFilter.Substring(0, StrFilter.Length - 4); } DV = dtFilter.DefaultView; DV.RowFilter = StrFilter; STRFILTER = StrFilter; this.Dispose(); } catch (Exception exc) { Utill.Common.ExceptionLogger.writeException("PurchaseInvoice", exc.StackTrace); MessageBox.Show(Utill.Common.CommonMessage.ExceptionMesg, "Exception"); } }
private void btnApply_Click(object sender, EventArgs e) { try { StrFilter = ""; if (txtReqNo.Text.Trim() != "") { StrFilter = StrFilter + " DNnumber Like '%" + PrepareFilterString(txtReqNo.Text.Trim()) + "%' And "; } if (txtCustomer.Text.Trim() != "") { StrFilter = StrFilter + " Name Like '%" + PrepareFilterString(txtCustomer.Text.Trim()) + "%' And "; } if (Convert.ToInt64(cmdAttendedBy.SelectedIndex) > 0) { StrFilter = StrFilter + " EmpID = " + cmdAttendedBy.SelectedValue + " And "; } if (DataValidator.IsDate(txtFromDate.Text.Trim())) { StrFilter = StrFilter + " DNDate >= '" + txtFromDate.Text.Trim() + "' And "; } if (DataValidator.IsDate(txtTodate.Text.Trim())) { StrFilter = StrFilter + " DNDate <= '" + txtTodate.Text.Trim() + "' And "; } if (StrFilter != "") { StrFilter = StrFilter.Substring(0, StrFilter.Length - 4); } DV = dtFilter.DefaultView; DV.RowFilter = StrFilter; STRFILTER = StrFilter; this.Dispose(); } catch (Exception exc) { Utill.Common.ExceptionLogger.writeException("Debit Note", exc.StackTrace); MessageBox.Show(Utill.Common.CommonMessage.ExceptionMesg, "Exception"); } }
private void SendEMail(string email) { string str; IList <MailAddress> list = new List <MailAddress>(); MailState none = MailState.None; MailInfo mailInfo = new MailInfo(); mailInfo.MailBody = base.MessageBody; mailInfo.Subject = base.MessageTitle; mailInfo.IsBodyHtml = true; if (this.m_SendType == SendType.SendToContacter) { str = "收货人"; } else { str = "会员"; } if (!string.IsNullOrEmpty(email) && DataValidator.IsEmail(email)) { list.Add(new MailAddress(email)); mailInfo.MailToAddressList = list; none = SendMail.Send(mailInfo); if (none == MailState.Ok) { base.SuccessMsg.Append("<br>已经向" + str + "发送了一封Email,通知他"); base.SuccessMsg.Append(base.OperationMsg); base.SuccessMsg.Append("!"); } else { string mailStateInfo = SendMail.GetMailStateInfo(none); base.ErrorMsg.Append("<br>"); base.ErrorMsg.Append(mailStateInfo); base.ErrorMsg.Append(",向" + str + "发送邮件失败!"); } } else { base.ErrorMsg.Append("<br>邮件地址为空或无效邮件地址,向" + str + "发送邮件失败!"); } }
/** * Login button * check the validity of the username and password * if all is valid check the authentication * if the authentication is good go to the TODOForm with the user object **/ private void btnLogin_Click(object sender, System.EventArgs e) { if (DataValidator.isValidTexts(txtUsername, txtPassword)) { if (auth.authenticate(new Authentication(txtUsername.Text, txtPassword.Text), true)) { this.Hide(); User user = new User(); user.setUsername(txtUsername.Text); BrainstormFrom textEditor = new BrainstormFrom(user, true); textEditor.Closed += (s, args) => this.Close(); //It creates a function "in place" that is called when the form2.Closed event is fired. textEditor.Show(); } else { MessageBox.Show(ErrorMessages.SOMETHING_WENT_WRONG(UserMessages.USERNAME_PASSWORD)); txtUsername.Focus(); } } }
public TEnumValue GetValueOrDefault <TEnumValue>( IRequestCookieCollection requestCookies, string key) where TEnumValue : struct, Enum { var enumValues = Enum.GetValues(typeof(TEnumValue)); DataValidator.ValidateNotEmptyCollection(enumValues, ErrorConstants.EmptyEnum); var defaultValueEnum = (TEnumValue)enumValues.GetValue(0); var valueString = requestCookies[key]; TEnumValue valueEnum; if (Enum.TryParse(valueString, out valueEnum) == false) { valueEnum = defaultValueEnum; } return(valueEnum); }
protected void EBtnBacthMove_Click(object sender, EventArgs e) { if (this.Page.IsValid) { int nodeId = DataConverter.CLng(this.DropNode.SelectedValue); string text = this.TxtGeneralId.Text; if (!DataValidator.IsValidId(text)) { AdminPage.WriteSuccessMsg("指定的内容ID不正确,请重新指定!", "ContentManage.aspx"); } if (ContentManage.BatchMove(text, nodeId)) { AdminPage.WriteSuccessMsg("批量移动成功!", "ContentManage.aspx"); } else { AdminPage.WriteErrMsg("批量移动失败!", "ContentManage.aspx"); } } }
/** * This method is a generic SQL Delete Query statment * * @tableName : The Table Name in the Database * @filter : the filter for the Where Statment * @condition : the condition for the Where statment * * It Throws and Exception when one of the parameters are invalid * * return an SQL Delete Statment **/ public String getDelete(String tableName, String filter, String condition) { //Validation if (!DataValidator.isValidParameters(tableName, filter, condition)) { throw new ArgumentException(Logging.paramenterLogging(nameof(getDelete), true, new Pair(nameof(tableName), tableName) , new Pair(nameof(filter), filter), new Pair(nameof(condition), condition))); } //Logging Logging.paramenterLogging(nameof(getDelete), false, new Pair(nameof(tableName), tableName) , new Pair(nameof(filter), filter), new Pair(nameof(condition), condition)); //Building the SQL Statment StringBuilder query = new StringBuilder(); query.Append("DELETE FROM "); query.Append(tableName); query.Append(getWhere(filter, condition)); query.Append(";"); return(query.ToString()); }
public void UpdatePet(Pet payload) { // Validate Payload DataValidator.ValidateGuid(payload.PetIdentifier); DataValidator.ValidateField(nameof(payload.LastHunger), payload.LastHunger); DataValidator.ValidateField(nameof(payload.LastHappiness), payload.LastHappiness); // Update User var updateResult = _storageService.UpdatePet(payload); // Check Update Result if (updateResult.ModifiedCount == 0) { throw new NoNullAllowedException("UserService (UpdateUser) - No updates were performed."); } if (updateResult.ModifiedCount > 1) { throw new InvalidOperationException("UserService (UpdateUser) - More than one user was updated."); } }
public void ValidateParameterTest() { var parameter = TestParameter.Create(); Assert.Throws <ValidationException>(() => DataValidator.ValidateParameter(parameter, null, true)); parameter = TestParameter.Create(); Assert.Throws <ValidationException>(() => DataValidator.ValidateParameter(parameter, new User { }, true)); parameter = TestParameter.Create(); DataValidator.ValidateParameter(parameter, new User { Account = "123" }, true); parameter = TestParameter.Create(); Assert.Throws <ValidationException>(() => DataValidator.ValidateParameter(parameter, new User { Account = "123456" }, true)); }
private void txtOpeningStock_Leave(object sender, EventArgs e) { TextBox txtTextbox = sender as TextBox; if (txtTextbox.Text != "") { if (DataValidator.IsNumeric(txtTextbox.Text)) { txtTextbox.Text = Convert.ToDecimal(txtTextbox.Text).ToString("#0.000"); // Set Decimal Value after textbox's Leave Event lblErrorMessage.Text = "No error"; int t = txtTextbox.TextLength; if (t <= txtTextbox.MaxLength) { btnSaveContinue.Enabled = true; btnSaveExit.Enabled = true; lblErrorMessage.Text = "No error"; txtCurrentStock.Text = txtOpeningStock.Text; } else { lblErrorMessage.Text = DataValidator.lblFormatMessage + "99999999999999.999"; txtTextbox.Focus(); btnSaveContinue.Enabled = false; btnSaveExit.Enabled = false; } } else { txtTextbox.Text = "0.000"; btnSaveContinue.Enabled = true; btnSaveExit.Enabled = true; } } else { txtTextbox.Text = "0.000"; btnSaveContinue.Enabled = true; btnSaveExit.Enabled = true; } }
public void TestProcessResult() { var validator = new DataValidator(); validator.SensorTypeFilter = new SensorType[] { SensorType.Data, SensorType.Entity, SensorType.Virtual }; for (int i = 0; i < 50; i++) { var source = new List <SensorAcqResult>(); source.Add( new SensorAcqResult { AcqTime = DateTime.Now, ErrorCode = 0, Sensor = new Sensor { SensorID = 990 }, Data = new SensorData(new double[] { 1, 2, 3 }, new double[] { 0.1, 0.2, 0.3 }, new double[] { 0.1, 0.2, 0.3 }) }); validator.ProcessResult(source); } var newData = new List <SensorAcqResult>(); newData.Add( new SensorAcqResult { AcqTime = DateTime.Now, ErrorCode = 0, Sensor = new Sensor { SensorID = 990 }, Data = new SensorData(new double[] { 1, 2, 3 }, new double[] { 1000, 100, 800 }, new double[] { 1000, 100, 800 }) }); validator.ProcessResult(newData); Assert.AreEqual(0.1, newData[0].Data.ThemeValues[0]); Assert.AreEqual(0.2, newData[0].Data.ThemeValues[1]); Assert.AreEqual(800, newData[0].Data.ThemeValues[2]); //没有过滤 }
private void btnApply_Click(object sender, EventArgs e) { try { StrFilter = ""; if (txtFromCode.Text.Trim() != "") { StrFilter = StrFilter + " SalesCode Like '%" + PrepareFilterString(txtFromCode.Text.Trim()) + "%' And "; } if (DataValidator.IsDate(txtFromDate.Text.Trim())) { StrFilter = StrFilter + " SalesDate >= '" + txtFromDate.Text.Trim() + "' And "; } if (DataValidator.IsDate(txtTodate.Text.Trim())) { StrFilter = StrFilter + " SalesDate <= '" + txtTodate.Text.Trim() + "' And "; } if (txtCompany.Text.Trim() != "") { StrFilter = StrFilter + " CustomerName Like '%" + PrepareFilterString(txtCompany.Text.Trim()) + "%' And "; } if (txtSrNo.Text.Trim() != "") { StrFilter = StrFilter + " SrNo Like '%" + PrepareFilterString(txtSrNo.Text.Trim()) + "%' And "; } if (StrFilter != "") { StrFilter = StrFilter.Substring(0, StrFilter.Length - 4); } DV = dtFilter.DefaultView; DV.RowFilter = StrFilter; this.Dispose(); } catch (Exception ex) { } }
public void UpdateUser(UserControllerRootPut payload) { // Validate Payload DataValidator.ValidateField(nameof(payload.UserIdentifier), payload.UserIdentifier); DataValidator.ValidateGuid(payload.UserIdentifier); DataValidator.ValidateField(nameof(payload.UserIdentifier), payload.UserName); // Update User var updateResult = _storageService.UpdateUser(payload.UserIdentifier, payload.UserName); // Check Update Result if (updateResult.ModifiedCount == 0) { throw new NoNullAllowedException("UserService (UpdateUser) - No updates were performed."); } if (updateResult.ModifiedCount > 1) { throw new InvalidOperationException("UserService (UpdateUser) - More than one user was updated."); } }
private static AddOnNotional ReadAddOnNotional(EntryObject o) { foreach (String property in s_Properties.Except(s_PropertiesAmount.Union(s_PropertiesCommon).Union(s_PropertiesTrade))) { if (!String.IsNullOrEmpty((String)o.GetType().GetProperty(property)?.GetValue(o))) { throw new InvalidDataException($"The CRIF file cannot specify the {property} property for Notional entries."); } } if (!DataValidator.IsValidNotionalQualifier(o.Qualifier)) { throw new InvalidDataException("The CRIF file contains a Notional entry with an invalid Qualifier property."); } Amount amount = ReadAmount(o); RegulationsInfo regulationsInfo = ReadRegulationsInfo(o); TradeInfo tradeInfo = ReadTradeInfo(o); return(AddOnNotional.OfUnchecked(o.Qualifier, amount, regulationsInfo, tradeInfo)); }
public async Task Handle(PayLoadCreatedDomainEvent payLoadCreatedEvent, CancellationToken cancellationToken) { string oppositeOrigin = (payLoadCreatedEvent.Origin == "Left" ? "Right" : "Left"); List <PayLoad> payLoadList = await _dataAuthorityRepository.GetPaylodAsync(payLoadCreatedEvent.ProvidedPayLoadId); if (payLoadList.Where(a => a.Origin == oppositeOrigin).Any()) { PayLoad left = payLoadList.FirstOrDefault(a => a.Origin == "Left"); PayLoad right = payLoadList.FirstOrDefault(a => a.Origin == "Right"); DataValidator validator = new DataValidator(left.Data, right.Data); DataDiffInsight dataDiff = validator.Diff(); string diffResult = JsonConvert.SerializeObject(dataDiff); await _dataAuthorityRepository.AddResult(payLoadCreatedEvent.ProvidedPayLoadId, diffResult); } }
public async Task SeedUserAsync(UserServiceModel model, string password, string roleName) { if (await this.IsUserExist(model.Email)) { return; } if (await this.IsRoleExist(roleName) == false) { throw new ArgumentException(ErrorConstants.RoleNotFound); } var dbUser = await this.CreateUserAsync(model, password); var result = await this.userManager.AddToRoleAsync(dbUser, roleName); DataValidator.ValidateIdentityResult(result); var rowsAffected = await this.userRepository.CompleteAsync(); RepositoryValidator.ValidateCompleteChanges(rowsAffected); }
public void test_quest_b() { string dataPath = "C:\\Work\\Edu_meter_sid_2014\\UIS_ED_A_2014_AT_import222.xml"; var dsd = StructureMessage.Load(@"C:\Work\Edu_meter_sid_2014\UOE.xml"); var keyFamily = dsd.KeyFamilies[0]; var validator = new DataValidator(keyFamily); int counter = 0; using (var reader = DataReader.Create(dataPath, keyFamily)) { reader.Map("OBS_STATUS", "OBS_STATUS", i => i == null ? i : ((string)i).ToUpper()); reader.ThrowExceptionIfNotValid = false; while (reader.Read()) { if (validator.Validate(reader).Count() > 0) { counter++; } } } Assert.AreEqual(0, counter); }