static void Main(string[] args) { // Active Record Methods using QueryBuilder // Fetch //Address Address = QueryBuilder.QueryBuilder<Address>.Init().Fetch(new Address { AddressID = 5 }); // Create //QueryBuilder.QueryBuilder<Address>.Init().Create(new Address() { Address1 = "123 Main", AddressTypeID = 1, City = "Irving", State = null, Country = 1 }); // Update //QueryBuilder.QueryBuilder<Address>.Init().Update(new Address() { AddressID = Address.AddressID, Address1 = "123 MainU", AddressTypeID = 1, City = "Irving", State = null, Country = 1 }); // Fetch using Active Record metaphor. // Fetch AR.Address Address = AR.Address.Fetch(5); // Create AR.Address AddressToCreate = new AR.Address() { Address1 = "123 Main", AddressTypeID = 1, City = "Irving", State = null, Country = 1 }; AddressToCreate.DoCreate(); // Update // You dont need to get the entity first to update it. Just set the properties you want to update AR.Address AddressToUpdate = new AR.Address(); // Set the primary key. This is required AddressToUpdate.AddressID = 5; // Now just set the fields you want to update AddressToUpdate.City = "IrvingU"; AddressToUpdate.DoUpdate(); // Delete. Not implemented yet // Builder pattern // Address builderAddress = ((AddressBuilder)BaseFixture<Address>.Init().Builder()).Inject(InjectionType.Create); // Build an Address but with some properties // Active Record AR.Address builderAddressWithOverride = BaseFixture<AR.Address>.Init().Inject(new AR.Address() { AddressTypeID = 1, Country = 1, City = "Irving" }, InjectionType.Create); // Entity Framework EF.Address address = EFFixture<EF.Address>.Init().Inject(new EF.Address() { AddressTypeID = 1, Country = 1, City = "Irving" }, InjectionType.Create); //Address Address = QueryBuilder.QueryBuilder<Address>.Init().Where(a => { a.City = "Irnving"; a.PostalCode = "76021"; }).Fetch(); var addr = new Address1(); var b = addr.SetBeforeFetch(a => { a.City = "Irving"; a.Postal = "76021"; }); }
public override int GetHashCode() { return(Address1.GetHashCode() ^ Address2.GetHashCode() ^ City.GetHashCode() ^ PostCode.GetHashCode()); }
public override int GetHashCode() { return(PostalCode.GetHashCodeIgnoreCase() ^ Address1.GetHashCodeIgnoreCase() ^ City.GetHashCodeIgnoreCase()); }
/// <summary> /// Returns true if Address instances are equal /// </summary> /// <param name="other">Instance of Address to be compared</param> /// <returns>Boolean</returns> public bool Equals(Address other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( ReferenceNumber == other.ReferenceNumber || ReferenceNumber != null && ReferenceNumber.Equals(other.ReferenceNumber) ) && ( FirstName == other.FirstName || FirstName != null && FirstName.Equals(other.FirstName) ) && ( LastName == other.LastName || LastName != null && LastName.Equals(other.LastName) ) && ( Address1 == other.Address1 || Address1 != null && Address1.Equals(other.Address1) ) && ( Address2 == other.Address2 || Address2 != null && Address2.Equals(other.Address2) ) && ( City == other.City || City != null && City.Equals(other.City) ) && ( State == other.State || State != null && State.Equals(other.State) ) && ( CountryCode == other.CountryCode || CountryCode != null && CountryCode.Equals(other.CountryCode) ) && ( PostalCode == other.PostalCode || PostalCode != null && PostalCode.Equals(other.PostalCode) ) && ( PhoneNumber == other.PhoneNumber || PhoneNumber != null && PhoneNumber.Equals(other.PhoneNumber) )); }
// Public Methods /// <summary> /// Ensures that all required fields are present. /// </summary> public CCResponse ValidateFields() { //Security Defect - Added the below code to trim all the fields FirstName = FirstName.Trim(); LastName = LastName.Trim(); City = City.Trim(); Zip = Zip.Trim(); Email = Email.Trim(); State = State.Trim(); Address1 = Address1.Trim(); Address2 = Address2.Trim(); Country = Country.Trim(); //Security Defect - Added the below code to trim all the fields CCResponse c = new CCResponse(); //Security Defects - START - Added the below lines to validate the fields in the BillToInfo if (IsMissing(FirstName)) { c.Message = CSAAWeb.Constants.ERR_AUTHVALIDATION + "FirstName"; c.ActualMessage = c.Message; c.Flag = Config.Setting("ERRCDE_FIRSTNAME"); Logger.Log(c.Message + c.Flag); return(c); } //Security Defects- CH4 -Commented the required field check for lastname since Empty spaces are coming from EXG in this field. //else if (IsMissing(LastName)) //{ // c.Message = CSAAWeb.Constants.ERR_AUTHVALIDATION + "LastName"; // c.ActualMessage = c.Message; // c.Flag = Config.Setting("ERRCDE_LASTNAME"); // Logger.Log(c.Message + c.Flag); // return c; //} //Security Defects-CH4 - Commented the required field check for lastname since Empty spaces are coming from EXG in this field. else if (IsMissing(City) || (City.Length > 25) || junkValidation(City)) { c.Message = CSAAWeb.Constants.ERR_AUTHVALIDATION + "City"; c.ActualMessage = c.Message; c.Flag = Config.Setting("ERRCDE_CITY"); Logger.Log(c.Message + c.Flag); return(c); } else if (IsMissing(Zip) || (Zip.Length > 10) || junkValidation(Zip) || !CSAAWeb.Validate.IsValidZip(Zip)) { c.Message = CSAAWeb.Constants.ERR_AUTHVALIDATION + "Zip"; c.ActualMessage = c.Message; c.Flag = Config.Setting("ERRCDE_CITY"); Logger.Log(c.Message + c.Flag); return(c); } else if ((Email.Length > 90) || (Email != "" && !CSAAWeb.Validate.IsValidEmailAddress(Email))) { c.Message = CSAAWeb.Constants.ERR_AUTHVALIDATION + "Email"; c.ActualMessage = c.Message; c.Flag = Config.Setting("ERRCDE_EMAIL"); Logger.Log(c.Message + c.Flag); return(c); } else if (IsMissing(State) || (State.Length > 2) || junkValidation(State)) { c.Message = CSAAWeb.Constants.ERR_AUTHVALIDATION + "State"; c.ActualMessage = c.Message; c.Flag = Config.Setting("ERRCDE_STATE"); Logger.Log(c.Message + c.Flag); return(c); } //Security defects -Ch3-Removed junk validation in BillToInfo field else if (IsMissing(Address1) || (Address1.Length > 40)) { c.Message = CSAAWeb.Constants.ERR_AUTHVALIDATION + "Address1"; c.Flag = Config.Setting("ERRCDE_ADDRESS1"); c.ActualMessage = c.Message; Logger.Log(c.Message + c.Flag); return(c); } //Security defects -Ch3-Removed junk validation in BillToInfo field else if ((Address2.Length > 40)) { c.Message = CSAAWeb.Constants.ERR_AUTHVALIDATION + "Address2"; c.ActualMessage = c.Message; c.Flag = Config.Setting("ERRCDE_ADDRESS2"); return(c); } else if ((Country.Length > 2) || junkValidation(Country)) { c.Message = CSAAWeb.Constants.ERR_AUTHVALIDATION + "Country"; c.ActualMessage = c.Message; c.Flag = Config.Setting("ERRCDE_COUNTRY"); return(c); } //Security Defects -CH1 - END- Added the below lines to validate the fields in the BillToInfo /*Security Defects - CH2 - sTART - Commented the below code * else if (IsMissing(FirstName) || IsMissing(LastName)) * { * Logger.Log("Field missing, FirstName=" + FirstName + ", LastName=" + LastName); * return null; * throw new BusinessRuleException(EXP_MISSING_CONTACT); * } * * // CSAA.COM CH1:START- Removed Address1 from required field check . * // if (IsMissing(Address1) || IsMissing(City) || IsMissing(State) || IsMissing(Zip)) * else if ( IsMissing(City) || IsMissing(State) || IsMissing(Zip)) * { * //Logger.Log("Field missing, Address1=" + Address1 + ", City=" + City + ", State=" + State + ", Zip=" + Zip); * Logger.Log("Field missing, City=" + City + ", State=" + State + ", Zip=" + Zip); * return null; * * throw new BusinessRuleException(EXP_MISSING_ADDRESS); * } * // CSAA.COM CH1:END-//Security Defects - CH2 - Commented the below code */ else if (IsMissing(Country)) { _Country = Default_Country; return(null); } else if (IsMissing(Currency)) { _Currency = Default_Currency; return(null); } else { return(null); } }
protected override void Execute(CodeActivityContext executionContext) { //Create the tracing service ITracingService tracingService = executionContext.GetExtension <ITracingService>(); //Create the context IWorkflowContext context = executionContext.GetExtension <IWorkflowContext>(); IOrganizationServiceFactory serviceFactory = executionContext.GetExtension <IOrganizationServiceFactory>(); IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId); tracingService.Trace("Loaded UpsertSupplierWorkflow"); tracingService.Trace("CREATING Contact object with the input values"); tracingService.Trace("Checkpoint 1"); Contact contact = new Contact(); int partyid = PartyID.Get <int>(executionContext); tracingService.Trace("Starting assigning attribute variables."); contact.First_Name = FirstName.Get <string>(executionContext).ToString(); tracingService.Trace("First Name Populated"); tracingService.Trace(string.Format("Setting party id = {0}", partyid)); contact.Party_Id = partyid; tracingService.Trace("Party ID populated"); contact.Last_Name = LastName.Get <string>(executionContext).ToString(); tracingService.Trace("Last Name Populated"); contact.Payment_Method = PaymentMethod.Get <string>(executionContext).ToString(); tracingService.Trace("Payment Method Populated"); contact.SIN = SIN.Get <string>(executionContext).ToString(); tracingService.Trace("SIN Populated"); contact.Address1 = Address1.Get <string>(executionContext).ToString(); tracingService.Trace("Address1 Populated"); contact.Country_Code = Country.Get <string>(executionContext).ToString(); tracingService.Trace("Country Populated"); contact.City = City.Get <string>(executionContext).ToString(); tracingService.Trace("City Populated"); contact.Province_Code = Province.Get <string>(executionContext).ToString(); tracingService.Trace("Province Populated"); contact.Postal_Code = PostalCode.Get <string>(executionContext).ToString(); tracingService.Trace("Postal Code Populated"); tracingService.Trace("Checkpoint 2"); EntityReference contactRef = ContactReference.Get <EntityReference>(executionContext); contact.ID = contactRef.Id; tracingService.Trace("Fetching the Configs"); ////Get the configuration record for Oracle_T4A group from the configs entity and get the connection value from the record. var configs = Helper.GetSystemConfigurations(service, ConfigEntity.Group.ORACLE_T4A, string.Empty); tracingService.Trace("Fetching Connection"); string connection = Helper.GetConfigKeyValue(configs, ConfigEntity.Key.CONNECTION, ConfigEntity.Group.ORACLE_T4A); try { tracingService.Trace("Fetching Oracle Response by making call to Helper.UpsertSupplierInOracle()"); OracleResponse response = Helper.UpsertSupplierInOracle(contact, connection, tracingService); if (response.TransactionCode == OracleResponse.T4A_STATUS.OK) { tracingService.Trace("Inside OracleResponse.T4A_STATUS.OK \nRetriving and setting response values to output"); PartyID.Set(executionContext, response.PartyId); tracingService.Trace("Party ID Output Param is set"); } tracingService.Trace("Setting up transaction code and transaction message"); TransactionCode.Set(executionContext, response.TransactionCode.Trim()); TransactionMessage.Set(executionContext, response.TransactionMessage); } catch (InvalidWorkflowException ex) { Helper.LogIntegrationError(service, ErrorType.CONTACT_ERROR, IntegrationErrorCodes.UPSERT_SUPPLIER.GetIntValue(), Strings.T4A_FER_ERROR, string.Format("Error Description: {0} ", ex.Message), contactRef); } catch (Exception ex) { Helper.LogIntegrationError(service, ErrorType.CONTACT_ERROR, IntegrationErrorCodes.UPSERT_SUPPLIER.GetIntValue(), Strings.T4A_FER_ERROR, string.Format("Error Description: {0} ", ex.Message), contactRef); } }
public string GenerateAddressHtmlString(string LineBreak) { StringBuilder sb = new StringBuilder(); if (Address1 != null && Address1.Trim() != "") { sb.Append(Address1 + LineBreak); } if (Address2 != null && Address2.Trim() != "") { sb.Append(Address2 + LineBreak); } if (Address3 != null && Address3.Trim() != "") { sb.Append(Address3 + LineBreak); } //CITY if (City != null && City != "") { sb.Append(City); if (StateCode != null && StateCode != "") { sb.Append(", "); } else if (PostalCode != null && PostalCode != "") { sb.Append(" "); } else if (CountryCode != null && CountryCode != "" && CountryCode.ToLower() != "us" && CountryCode.ToLower() != "usa") { sb.Append("; "); } } //STATE if (StateCode != null && StateCode != "") { sb.Append(StateCode); if (PostalCode != null && PostalCode != "") { sb.Append(" "); } else if (CountryCode != null && CountryCode != "" && CountryCode.ToLower() != "us" && CountryCode.ToLower() != "usa") { sb.Append("; "); } } //POSTAL if (PostalCode != null && PostalCode != "") { sb.Append(PostalCode); if (CountryCode != null && CountryCode != "" && CountryCode.ToLower() != "us" && CountryCode.ToLower() != "usa") { sb.Append(LineBreak); } } //COUNTRY if (CountryCode != null && CountryCode != "" && CountryCode.ToLower() != "us" && CountryCode.ToLower() != "usa") { sb.Append(CountryCode); } sb.Append(LineBreak); return(sb.ToString()); }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { // credit: http://stackoverflow.com/a/263416/677735 unchecked // Overflow is fine, just wrap { int hash = 41; // Suitable nullity checks hash = hash * 59 + Id.GetHashCode(); if (GivenName != null) { hash = hash * 59 + GivenName.GetHashCode(); } if (Surname != null) { hash = hash * 59 + Surname.GetHashCode(); } if (Role != null) { hash = hash * 59 + Role.GetHashCode(); } if (Notes != null) { hash = hash * 59 + Notes.GetHashCode(); } if (EmailAddress != null) { hash = hash * 59 + EmailAddress.GetHashCode(); } if (WorkPhoneNumber != null) { hash = hash * 59 + WorkPhoneNumber.GetHashCode(); } if (MobilePhoneNumber != null) { hash = hash * 59 + MobilePhoneNumber.GetHashCode(); } if (FaxPhoneNumber != null) { hash = hash * 59 + FaxPhoneNumber.GetHashCode(); } if (Address1 != null) { hash = hash * 59 + Address1.GetHashCode(); } if (Address2 != null) { hash = hash * 59 + Address2.GetHashCode(); } if (City != null) { hash = hash * 59 + City.GetHashCode(); } if (Province != null) { hash = hash * 59 + Province.GetHashCode(); } if (PostalCode != null) { hash = hash * 59 + PostalCode.GetHashCode(); } return(hash); } }
/// <summary> /// Simplify address /// </summary> /// <remarks> /// This basically is intended to remove empty lines from the address fields and push the remainder up. /// It can mess up the consistency for named fields but that is always a risk with user input /// Postcode is ignored - previously it may have been added to the last line /// </remarks> public void Simplify() { var dummyLine = "##DUMMY ADDRESS LINE##"; // first tidy up Address1 = Address1 == null ? "" : Address1.Trim(); Address2 = Address2 == null ? "" : Address2.Trim(); Address3 = Address3 == null ? "" : Address3.Trim(); Address4 = Address4 == null ? "" : Address4.Trim(); Address5 = Address5 == null ? "" : Address5.Trim(); Address6 = Address6 == null ? "" : Address6.Trim(); // check for house number // we only check the first two addresses and deal if needed // house number is intended to be in address 2 but it could be swapped so we check here var houseNameIsNumeric = Address1.Trim().IsLong(); var houseNameIsPartialNumeric = Address1.Trim().FirstWord().IsLong(); var houseNumberIsNumeric = Address2.Trim().IsLong(); var houseNumberIsPartialNumeric = Address2.Trim().FirstWord().IsLong(); if (houseNameIsNumeric) { long.TryParse(Address1, out var houseNumber); // address1 is fully numeric so we swap Address1 = Address2 == null || Address2.Trim() == "" ? dummyLine : Address2; Address2 = houseNumber.ToString(); } else { if (houseNameIsPartialNumeric) { // address1 is partial numeric, if address2 is empty we move the number if (Address2 == null || Address2.Trim() == "") { long.TryParse(Address1.Trim().FirstWord(), out var houseNumber); Address1 = Address1.Substring(houseNumber.ToString().Length); Address2 = houseNumber.ToString(); } } else { if (houseNumberIsNumeric && (Address1 == null || Address1.Trim() == "")) { // housenumber is numeric and house nameis empty so we add dummy line to prevent losing empty line which will throw out the order Address1 = dummyLine; } else { if (houseNumberIsPartialNumeric && (Address1 == null || Address1.Trim() == "")) { // housenumber contains a partial numeric e.g. 32 High street so we split it out long.TryParse(Address2.Trim().FirstWord(), out var house2Number); Address1 = Address2.Substring(house2Number.ToString().Length); Address2 = house2Number.ToString(); } } } } var tempFullAddress = FullAddress(Address1, Address2, Address3, Address4, Address5, Address6, false); // remove any redundancy so that we have a comma separated string tempFullAddress.ReplaceAllMid(",,", "", 0, tempFullAddress.Length); // now split on comma var tempAddress = tempFullAddress.Split(','); var tempAddressLen = tempAddress.Length; switch (tempAddressLen) { case 1: Address1 = tempAddress[0].Trim(); Address2 = ""; Address3 = ""; Address4 = ""; Address5 = ""; Address6 = ""; break; case 2: Address1 = tempAddress[0].Trim(); Address2 = tempAddress[1].Trim(); Address3 = ""; Address4 = ""; Address5 = ""; Address6 = ""; break; case 3: Address1 = tempAddress[0].Trim(); Address2 = tempAddress[1].Trim(); Address3 = tempAddress[2].Trim(); Address4 = ""; Address5 = ""; Address6 = ""; break; case 4: Address1 = tempAddress[0].Trim(); Address2 = tempAddress[1].Trim(); Address3 = tempAddress[2].Trim(); Address4 = tempAddress[3].Trim(); Address5 = ""; Address6 = ""; break; case 5: Address1 = tempAddress[0].Trim(); Address2 = tempAddress[1].Trim(); Address3 = tempAddress[2].Trim(); Address4 = tempAddress[3].Trim(); Address5 = tempAddress[4].Trim(); Address6 = ""; break; case 6: Address1 = tempAddress[0].Trim(); Address2 = tempAddress[1].Trim(); Address3 = tempAddress[2].Trim(); Address4 = tempAddress[3].Trim(); Address5 = tempAddress[4].Trim(); Address6 = tempAddress[5].Trim(); break; default: Address1 = tempAddress[0].Trim(); Address2 = tempAddress[1].Trim(); Address3 = tempAddress[2].Trim(); Address4 = tempAddress[3].Trim(); Address5 = tempAddress[4].Trim(); Address6 = tempAddress[5].Trim(); break; } // now remove dummy if it exists if (Address1 == dummyLine) { Address1 = ""; } }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { // credit: http://stackoverflow.com/a/263416/677735 unchecked // Overflow is fine, just wrap { int hash = 41; // Suitable nullity checks hash = hash * 59 + Id.GetHashCode(); if (OwnerCode != null) { hash = hash * 59 + OwnerCode.GetHashCode(); } if (OrganizationName != null) { hash = hash * 59 + OrganizationName.GetHashCode(); } hash = hash * 59 + MeetsResidency.GetHashCode(); if (LocalArea != null) { hash = hash * 59 + LocalArea.GetHashCode(); } if (Status != null) { hash = hash * 59 + Status.GetHashCode(); } if (StatusComment != null) { hash = hash * 59 + StatusComment.GetHashCode(); } if (DoingBusinessAs != null) { hash = hash * 59 + DoingBusinessAs.GetHashCode(); } if (RegisteredCompanyNumber != null) { hash = hash * 59 + RegisteredCompanyNumber.GetHashCode(); } if (PrimaryContact != null) { hash = hash * 59 + PrimaryContact.GetHashCode(); } if (IsMaintenanceContractor != null) { hash = hash * 59 + IsMaintenanceContractor.GetHashCode(); } if (WorkSafeBCPolicyNumber != null) { hash = hash * 59 + WorkSafeBCPolicyNumber.GetHashCode(); } if (WorkSafeBCExpiryDate != null) { hash = hash * 59 + WorkSafeBCExpiryDate.GetHashCode(); } if (GivenName != null) { hash = hash * 59 + GivenName.GetHashCode(); } if (Surname != null) { hash = hash * 59 + Surname.GetHashCode(); } if (Address1 != null) { hash = hash * 59 + Address1.GetHashCode(); } if (Address2 != null) { hash = hash * 59 + Address2.GetHashCode(); } if (City != null) { hash = hash * 59 + City.GetHashCode(); } if (Province != null) { hash = hash * 59 + Province.GetHashCode(); } if (PostalCode != null) { hash = hash * 59 + PostalCode.GetHashCode(); } if (CGLEndDate != null) { hash = hash * 59 + CGLEndDate.GetHashCode(); } if (CglPolicyNumber != null) { hash = hash * 59 + CglPolicyNumber.GetHashCode(); } if (ArchiveCode != null) { hash = hash * 59 + ArchiveCode.GetHashCode(); } if (ArchiveReason != null) { hash = hash * 59 + ArchiveReason.GetHashCode(); } if (ArchiveDate != null) { hash = hash * 59 + ArchiveDate.GetHashCode(); } if (Contacts != null) { hash = hash * 59 + Contacts.GetHashCode(); } if (Notes != null) { hash = hash * 59 + Notes.GetHashCode(); } if (Attachments != null) { hash = hash * 59 + Attachments.GetHashCode(); } if (History != null) { hash = hash * 59 + History.GetHashCode(); } if (EquipmentList != null) { hash = hash * 59 + EquipmentList.GetHashCode(); } return(hash); } }
/// <summary> /// Returns true if Owner instances are equal /// </summary> /// <param name="other">Instance of Owner to be compared</param> /// <returns>Boolean</returns> public bool Equals(Owner other) { if (other is null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( Id == other.Id || Id.Equals(other.Id) ) && ( OwnerCode == other.OwnerCode || OwnerCode != null && OwnerCode.Equals(other.OwnerCode) ) && ( OrganizationName == other.OrganizationName || OrganizationName != null && OrganizationName.Equals(other.OrganizationName) ) && ( MeetsResidency == other.MeetsResidency || MeetsResidency.Equals(other.MeetsResidency) ) && ( LocalArea == other.LocalArea || LocalArea != null && LocalArea.Equals(other.LocalArea) ) && ( Status == other.Status || Status != null && Status.Equals(other.Status) ) && ( StatusComment == other.StatusComment || StatusComment != null && StatusComment.Equals(other.StatusComment) ) && ( DoingBusinessAs == other.DoingBusinessAs || DoingBusinessAs != null && DoingBusinessAs.Equals(other.DoingBusinessAs) ) && ( RegisteredCompanyNumber == other.RegisteredCompanyNumber || RegisteredCompanyNumber != null && RegisteredCompanyNumber.Equals(other.RegisteredCompanyNumber) ) && ( PrimaryContact == other.PrimaryContact || PrimaryContact != null && PrimaryContact.Equals(other.PrimaryContact) ) && ( IsMaintenanceContractor == other.IsMaintenanceContractor || IsMaintenanceContractor != null && IsMaintenanceContractor.Equals(other.IsMaintenanceContractor) ) && ( WorkSafeBCPolicyNumber == other.WorkSafeBCPolicyNumber || WorkSafeBCPolicyNumber != null && WorkSafeBCPolicyNumber.Equals(other.WorkSafeBCPolicyNumber) ) && ( WorkSafeBCExpiryDate == other.WorkSafeBCExpiryDate || WorkSafeBCExpiryDate != null && WorkSafeBCExpiryDate.Equals(other.WorkSafeBCExpiryDate) ) && ( GivenName == other.GivenName || GivenName != null && GivenName.Equals(other.GivenName) ) && ( Surname == other.Surname || Surname != null && Surname.Equals(other.Surname) ) && ( Address1 == other.Address1 || Address1 != null && Address1.Equals(other.Address1) ) && ( Address2 == other.Address2 || Address2 != null && Address2.Equals(other.Address2) ) && ( City == other.City || City != null && City.Equals(other.City) ) && ( Province == other.Province || Province != null && Province.Equals(other.Province) ) && ( PostalCode == other.PostalCode || PostalCode != null && PostalCode.Equals(other.PostalCode) ) && ( CGLEndDate == other.CGLEndDate || CGLEndDate != null && CGLEndDate.Equals(other.CGLEndDate) ) && ( CglPolicyNumber == other.CglPolicyNumber || CglPolicyNumber != null && CglPolicyNumber.Equals(other.CglPolicyNumber) ) && ( ArchiveCode == other.ArchiveCode || ArchiveCode != null && ArchiveCode.Equals(other.ArchiveCode) ) && ( ArchiveReason == other.ArchiveReason || ArchiveReason != null && ArchiveReason.Equals(other.ArchiveReason) ) && ( ArchiveDate == other.ArchiveDate || ArchiveDate != null && ArchiveDate.Equals(other.ArchiveDate) ) && ( Contacts == other.Contacts || Contacts != null && Contacts.SequenceEqual(other.Contacts) ) && ( Notes == other.Notes || Notes != null && Notes.SequenceEqual(other.Notes) ) && ( Attachments == other.Attachments || Attachments != null && Attachments.SequenceEqual(other.Attachments) ) && ( History == other.History || History != null && History.SequenceEqual(other.History) ) && ( EquipmentList == other.EquipmentList || EquipmentList != null && EquipmentList.SequenceEqual(other.EquipmentList) )); }
public override bool Encode(ref byte[] buffer) { /* First : determine the total number of characters */ int NbBytes = count_nb_bytes(); /* Second : create the whole byte array */ int index = 0; int new_index; byte[] pl = new byte[NbBytes]; new_index = AddLine(pl, pl.Length, index, "BEGIN:VCARD", ""); if (new_index < 0) { Trace.WriteLine("Error generating 'VCard' object: after 'BEGIN'"); return(false); } index = new_index; new_index = AddLine(pl, pl.Length, index, "VERSION:3.0", ""); if (new_index < 0) { Trace.WriteLine("Error generating 'VCard' object: after 'VERSION'"); return(false); } index = new_index; string name = _first_name + " " + _family_name; new_index = AddLine(pl, pl.Length, index, "FN:", name); if (new_index < 0) { Trace.WriteLine("Error generating 'VCard' object: after 'FN'"); return(false); } index = new_index; if (!Nickname.Equals("")) { new_index = AddLine(pl, pl.Length, index, "NICKNAME:", Nickname); if (new_index < 0) { Trace.WriteLine("Error generating 'VCard' object: after 'Nickname'"); return(false); } index = new_index; } DateTime dateBirthday; if ((!Birthday.Equals("")) && (DateTime.TryParse(Birthday, out dateBirthday))) { string Bday = convert_into_vcard_date(Birthday); new_index = AddLine(pl, pl.Length, index, "BDAY:", Bday); if (new_index < 0) { Trace.WriteLine("Error generating 'VCard' object: after 'Birthday'"); return(false); } index = new_index; } if (!(Address1.Equals("")) || !(Address2.Equals("")) || !(Town.Equals("")) || !(Region_State.Equals("")) || !(Post_Code.Equals("")) || !(Country.Equals("")) ) { string addr_line = Address1 + ";" + Address2 + ";" + Town + ";" + Region_State + ";" + Post_Code + ";" + Country; new_index = AddLine(pl, pl.Length, index, "ADR:;", addr_line); if (new_index < 0) { Trace.WriteLine("Error generating 'VCard' object: after 'Address'"); return(false); } index = new_index; } if (!(Pro_Address1.Equals("")) || !(Pro_Address2.Equals("")) || !(Pro_Town.Equals("")) || !(Pro_Region_State.Equals("")) || !(Pro_Post_Code.Equals("")) || !(Pro_Country.Equals("")) ) { string pro_addr_line = Pro_Address1 + ";" + Pro_Address2 + ";" + Pro_Town + ";" + Pro_Region_State + ";" + Pro_Post_Code + ";" + Pro_Country; new_index = AddLine(pl, pl.Length, index, "ADR;TYPE=work:;", pro_addr_line); if (new_index < 0) { Trace.WriteLine("Error generating 'VCard' object: after 'Professional Address'"); return(false); } index = new_index; } if (!Home_phone.Equals("")) { new_index = AddLine(pl, pl.Length, index, "TEL;TYPE=home:", Home_phone); if (new_index < 0) { Trace.WriteLine("Error generating 'VCard' object: after 'TEL;TYPE=home'"); return(false); } index = new_index; } if (!Business_phone.Equals("")) { new_index = AddLine(pl, pl.Length, index, "TEL;TYPE=work:", Business_phone); if (new_index < 0) { Trace.WriteLine("Error generating 'VCard' object: after 'TEL;TYPE=work'"); return(false); } index = new_index; } if (!Cell_phone.Equals("")) { new_index = AddLine(pl, pl.Length, index, "TEL;TYPE=cell:", Cell_phone); if (new_index < 0) { Trace.WriteLine("Error generating 'VCard' object: after 'TEL;TYPE=cell'"); return(false); } index = new_index; } if (!Pager.Equals("")) { new_index = AddLine(pl, pl.Length, index, "TEL;TYPE=pager:", Pager); if (new_index < 0) { Trace.WriteLine("Error generating 'VCard' object: after 'TEL;TYPE=pager'"); return(false); } index = new_index; } if (!Fax.Equals("")) { new_index = AddLine(pl, pl.Length, index, "TEL;TYPE=fax:", Fax); if (new_index < 0) { Trace.WriteLine("Error generating 'VCard' object: after 'TEL;TYPE=fax'"); return(false); } index = new_index; } if (!Email.Equals("")) { if (Email_alternative.Equals("")) { new_index = AddLine(pl, pl.Length, index, "EMAIL:", Email); if (new_index < 0) { Trace.WriteLine("Error generating 'VCard' object: after 'EMAIL'"); return(false); } index = new_index; } else { /* Two E-mails to add */ new_index = AddLine(pl, pl.Length, index, "EMAIL;PREF=1:", Email); if (new_index < 0) { Trace.WriteLine("Error generating 'VCard' object: after 'EMAIL;PREF=1'"); return(false); } index = new_index; new_index = AddLine(pl, pl.Length, index, "EMAIL;PREF=2:", Email_alternative); if (new_index < 0) { Trace.WriteLine("Error generating 'VCard' object: after 'EMAIL;PREF=2'"); return(false); } index = new_index; } } if (!Title.Equals("")) { new_index = AddLine(pl, pl.Length, index, "TITLE:", Title); if (new_index < 0) { Trace.WriteLine("Error generating 'VCard' object: after 'TITLE'"); return(false); } index = new_index; } if (!Role.Equals("")) { new_index = AddLine(pl, pl.Length, index, "ROLE:", Role); if (new_index < 0) { Trace.WriteLine("Error generating 'VCard' object: after 'ROLE'"); return(false); } index = new_index; } if (!Company.Equals("")) { new_index = AddLine(pl, pl.Length, index, "ORG:", Company); if (new_index < 0) { Trace.WriteLine("Error generating 'VCard' object: after 'ORG'"); return(false); } index = new_index; } if (!_photo.Equals("")) { new_index = AddLine(pl, pl.Length, index, "PHOTO;ENCODING=BASE64;TYPE=JPEG:", _photo); if (new_index < 0) { Trace.WriteLine("Error generating 'VCard' object: after 'PHOTO'"); return(false); } index = new_index; } new_index = AddLine(pl, pl.Length, index, "END:VCARD", ""); _payload = pl; return(base.Encode(ref buffer)); }
private int count_nb_bytes() { /* All the ASCII strings in the VCard must be separated by 0x0D0A, which represent 2 characters */ int NbBytes = 0; NbBytes = "BEGIN:VCARD".Length + 2 + "VERSION:3.0".Length + 2; NbBytes += "FN:".Length + First_name.Length + 1 + Family_name.Length + 2; /* 1 is for "space" */ if (!Nickname.Equals("")) { NbBytes += "NICKNAME:".Length + Nickname.Length + 2; } /* Birthday with 8 characters: yyyymmdd */ DateTime dateBirthday; if ((!Birthday.Equals("")) && (DateTime.TryParse(Birthday, out dateBirthday))) { NbBytes += "BDAY:".Length + 8 + 2; } /* Home address in 6 fields, separated by a ';' */ /* The PO Box is discarded, which explains the first ';' */ if (!(Address1.Equals("")) || !(Address2.Equals("")) || !(Town.Equals("")) || !(Region_State.Equals("")) || !(Post_Code.Equals("")) || !(Country.Equals("")) ) { NbBytes += "ADR:;".Length + Address1.Length + 1 + Address2.Length + 1 + Town.Length + 1 + Region_State.Length + 1 + Post_Code.Length + 1 + Country.Length + 2; } /* Work address in 6 fields, separated by a ';' */ /* The PO Box is discarded, which explains the first ';' */ if (!(Pro_Address1.Equals("")) || !(Pro_Address2.Equals("")) || !(Pro_Town.Equals("")) || !(Pro_Region_State.Equals("")) || !(Pro_Post_Code.Equals("")) || !(Pro_Country.Equals("")) ) { NbBytes += "ADR;TYPE=work:;".Length + Pro_Address1.Length + 1 + Pro_Address2.Length + 1 + Pro_Town.Length + 1 + Pro_Region_State.Length + 1 + Pro_Post_Code.Length + 1 + Pro_Country.Length + 2; } if (!Home_phone.Equals("")) { NbBytes += "TEL;TYPE=home:".Length + Home_phone.Length + 2; } if (!Business_phone.Equals("")) { NbBytes += "TEL;TYPE=work:".Length + Business_phone.Length + 2; } if (!Cell_phone.Equals("")) { NbBytes += "TEL;TYPE=cell:".Length + Cell_phone.Length + 2; } if (!Fax.Equals("")) { NbBytes += "TEL;TYPE=fax:".Length + Fax.Length + 2; } if (!Pager.Equals("")) { NbBytes += "TEL;TYPE=pager:".Length + Pager.Length + 2; } if (!Email.Equals("")) { if (Email_alternative.Equals("")) { NbBytes += "EMAIL:".Length + Email.Length + 2; } else { /* TWO EMAILS : PREF=1 and PREF=2 */ NbBytes += "EMAIL;PREF=1:".Length + Email.Length + 2 + "EMAIL;PREF=2:".Length + Email_alternative.Length + 2; } } if (!Title.Equals("")) { NbBytes += "TITLE:".Length + Title.Length + 2; } if (!Role.Equals("")) { NbBytes += "ROLE:".Length + Role.Length + 2; } if (!Company.Equals("")) { NbBytes += "ORG:".Length + Company.Length + 2; } if (!_photo.Equals("")) { NbBytes += "PHOTO;ENCODING=BASE64;TYPE=JPEG:".Length + _photo.Length + 2; } NbBytes += "END:VCARD".Length + 2; return(NbBytes); }
public override int GetHashCode() { int hash = 1; if (entityId_ != null) { hash ^= EntityId.GetHashCode(); } if (Description.Length != 0) { hash ^= Description.GetHashCode(); } if (checkinTimeOfDay_ != null) { hash ^= CheckinTimeOfDay.GetHashCode(); } if (checkOutTimeOfDay_ != null) { hash ^= CheckOutTimeOfDay.GetHashCode(); } if (rolloverTimeOfDay_ != null) { hash ^= RolloverTimeOfDay.GetHashCode(); } if (AllowedEarlyCheckinHours != 0) { hash ^= AllowedEarlyCheckinHours.GetHashCode(); } if (IifDocnumPrefix.Length != 0) { hash ^= IifDocnumPrefix.GetHashCode(); } if (IifCustomerName.Length != 0) { hash ^= IifCustomerName.GetHashCode(); } if (checkinDeposit_ != null) { hash ^= CheckinDeposit.GetHashCode(); } if (lastRevenueAccrualStart_ != null) { hash ^= LastRevenueAccrualStart.GetHashCode(); } if (lastDateHkRolloverRan_ != null) { hash ^= LastDateHkRolloverRan.GetHashCode(); } if (Address1.Length != 0) { hash ^= Address1.GetHashCode(); } if (Address2.Length != 0) { hash ^= Address2.GetHashCode(); } if (City.Length != 0) { hash ^= City.GetHashCode(); } if (State.Length != 0) { hash ^= State.GetHashCode(); } if (Zip.Length != 0) { hash ^= Zip.GetHashCode(); } if (PhoneNumber.Length != 0) { hash ^= PhoneNumber.GetHashCode(); } if (cardMerchant_ != null) { hash ^= CardMerchant.GetHashCode(); } if (cancellationPolicy_ != null) { hash ^= CancellationPolicy.GetHashCode(); } if (maximumAuthorizationAmount_ != null) { hash ^= MaximumAuthorizationAmount.GetHashCode(); } if (DefaultStayLength != 0) { hash ^= DefaultStayLength.GetHashCode(); } if (Website.Length != 0) { hash ^= Website.GetHashCode(); } if (ReservationEmail.Length != 0) { hash ^= ReservationEmail.GetHashCode(); } if (FaxNumber.Length != 0) { hash ^= FaxNumber.GetHashCode(); } if (BookingPrefix.Length != 0) { hash ^= BookingPrefix.GetHashCode(); } if (VoidAuthorizationsAfterDays != 0) { hash ^= VoidAuthorizationsAfterDays.GetHashCode(); } if (NoShowDelayHours != 0) { hash ^= NoShowDelayHours.GetHashCode(); } return(hash); }
public static Address Create(Address1 address1, Address2 address2, City city, State state, PostalCode postalCode) => new Address(address1, address2, city, state, postalCode);
public bool hasAddress1() { return(Address1 != null && Address1.Trim().Length != 0); }
private Contact1 CreateContact() { Country england = model.Countries.Single(c => c.Name == "UK - England"); int addressId = GetNextId(); Address1 address = new Address1 { Id = IntegerToGuid(addressId), PrimaryName = string.Format("Address {0} Primary Name", addressId), SecondaryName = string.Format("Address {0} Secondary Name", addressId), Street = string.Format("Address {0} Street", addressId), Town = string.Format("Address {0} Town", addressId), Locality = string.Format("Address {0} Locality", addressId), AdministrativeArea = string.Format("Address {0} Admin Area", addressId), PostCode = string.Format("Address {0} Post Code", addressId), Country = england, CountryId = england.Id, }; model.Address1.Add(address); int contactId = GetNextId(); Contact1 contact = new Contact1 { Id = IntegerToGuid(contactId), Title = string.Format("Contact {0} Title", contactId), Forename = string.Format("Contact {0} Forename", contactId), Surname = string.Format("Contact {0} Surname", contactId), Telephone = string.Format("Contact {0} Telephone", contactId), Mobile = string.Format("Contact {0} Mobile", contactId), Fax = string.Format("Contact {0} Fax", contactId), Email = string.Format("Contact {0} Email", contactId), Address1 = address, AddressId = address.Id, }; model.Contact1.Add(contact); return contact; }
/// <summary> /// Returns true if Contact instances are equal /// </summary> /// <param name="other">Instance of Contact to be compared</param> /// <returns>Boolean</returns> public bool Equals(Contact other) { if (other is null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( Id == other.Id || Id.Equals(other.Id) ) && ( GivenName == other.GivenName || GivenName != null && GivenName.Equals(other.GivenName) ) && ( Surname == other.Surname || Surname != null && Surname.Equals(other.Surname) ) && ( Role == other.Role || Role != null && Role.Equals(other.Role) ) && ( Notes == other.Notes || Notes != null && Notes.Equals(other.Notes) ) && ( EmailAddress == other.EmailAddress || EmailAddress != null && EmailAddress.Equals(other.EmailAddress) ) && ( WorkPhoneNumber == other.WorkPhoneNumber || WorkPhoneNumber != null && WorkPhoneNumber.Equals(other.WorkPhoneNumber) ) && ( MobilePhoneNumber == other.MobilePhoneNumber || MobilePhoneNumber != null && MobilePhoneNumber.Equals(other.MobilePhoneNumber) ) && ( FaxPhoneNumber == other.FaxPhoneNumber || FaxPhoneNumber != null && FaxPhoneNumber.Equals(other.FaxPhoneNumber) ) && ( Address1 == other.Address1 || Address1 != null && Address1.Equals(other.Address1) ) && ( Address2 == other.Address2 || Address2 != null && Address2.Equals(other.Address2) ) && ( City == other.City || City != null && City.Equals(other.City) ) && ( Province == other.Province || Province != null && Province.Equals(other.Province) ) && ( PostalCode == other.PostalCode || PostalCode != null && PostalCode.Equals(other.PostalCode) )); }