Exemplo n.º 1
0
        public virtual void Save(Context context)
        {
            if (AddressNo != null)
            {
                AddressNo.Persist(context);
            }
            if (Building != null)
            {
                Building.Persist(context);
            }
            if (Street1 != null)
            {
                Street1.Persist(context);
            }
            if (Street2 != null)
            {
                Street2.Persist(context);
            }

            if (regionLevel1Name != null)
            {
                regionLevel1Name.Persist(context);
            }
            if (regionLevel2Name != null)
            {
                regionLevel2Name.Persist(context);
            }
            if (regionLevel3Name != null)
            {
                regionLevel3Name.Persist(context);
            }

            context.PersistenceSession.SaveOrUpdate(this);
        }
Exemplo n.º 2
0
        protected override void Execute(CodeActivityContext executionContext)
        {
            // Extract the tracing service
            ITracingService tracingService = executionContext.GetExtension <ITracingService>();

            try
            {
                //Create the context
                IWorkflowContext            context        = executionContext.GetExtension <IWorkflowContext>();
                IOrganizationServiceFactory serviceFactory = executionContext.GetExtension <IOrganizationServiceFactory>();
                IOrganizationService        service        = serviceFactory.CreateOrganizationService(context.UserId);

                // Don't Really Care about which entity this is
                DynamicUrlParser parser        = new DynamicUrlParser();
                EntityReference  primaryEntity = parser.ConvertToEntityReference(service, RecordUrl.Get <string>(executionContext));

                string addressLine1    = Street1.Get <string>(executionContext);
                string addressLine2    = Street2.Get <string>(executionContext);
                string city            = City.Get <string>(executionContext);
                string stateOrProvince = StateOrProvince.Get <string>(executionContext);
                string zipCode         = ZipPostalCode.Get <string>(executionContext);
                string countryName     = Country.Get <string>(executionContext);

                string rc = GenerateAddress(addressLine1, addressLine2, city, stateOrProvince, zipCode, countryName);
                FullAddress.Set(executionContext, rc);
            }
            catch (FaultException <OrganizationServiceFault> ex)
            {
                throw new Exception("SBS.Workflow.SetStateChildRecords: " + ex.Message);
            }
        }
Exemplo n.º 3
0
        public override bool Equals(object obj)
        {
            Address addr = obj as Address;

            return(addr != null &&
                   Street1.Equals(addr.Street1, StringComparison.OrdinalIgnoreCase) &&
                   Street2.Equals(addr.Street2, StringComparison.OrdinalIgnoreCase) &&
                   PostalCode.Equals(addr.PostalCode, StringComparison.OrdinalIgnoreCase) &&
                   RegionCode.Equals(addr.RegionCode, StringComparison.OrdinalIgnoreCase) &&
                   CountryCode.Equals(addr.CountryCode, StringComparison.OrdinalIgnoreCase));
        }
Exemplo n.º 4
0
 public override int GetHashCode()
 {
     unchecked
     {
         int hashCode = (Street1 != null ? Street1.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Street2 != null ? Street2.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (City != null ? City.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (State != null ? State.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Zip != null ? Zip.GetHashCode() : 0);
         return(hashCode);
     }
 }
Exemplo n.º 5
0
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (City != null)
         {
             hashCode = hashCode * 59 + City.GetHashCode();
         }
         if (Country != null)
         {
             hashCode = hashCode * 59 + Country.GetHashCode();
         }
         if (EmailAddress != null)
         {
             hashCode = hashCode * 59 + EmailAddress.GetHashCode();
         }
         if (FaxNumber != null)
         {
             hashCode = hashCode * 59 + FaxNumber.GetHashCode();
         }
         if (PhoneNumber != null)
         {
             hashCode = hashCode * 59 + PhoneNumber.GetHashCode();
         }
         if (PostCode != null)
         {
             hashCode = hashCode * 59 + PostCode.GetHashCode();
         }
         if (StateOrProvince != null)
         {
             hashCode = hashCode * 59 + StateOrProvince.GetHashCode();
         }
         if (Street1 != null)
         {
             hashCode = hashCode * 59 + Street1.GetHashCode();
         }
         if (Street2 != null)
         {
             hashCode = hashCode * 59 + Street2.GetHashCode();
         }
         if (MediumCharacteristicType != null)
         {
             hashCode = hashCode * 59 + MediumCharacteristicType.GetHashCode();
         }
         return(hashCode);
     }
 }
Exemplo n.º 6
0
        public override bool Equals(object obj)
        {
            bool result = false;

            try
            {
                Address compareTo = (Address)obj;
                result = Street1.Equals(compareTo.Street1, StringComparison.CurrentCultureIgnoreCase) &&
                         City.Equals(compareTo.City, StringComparison.CurrentCultureIgnoreCase);
            }
            catch
            {
                result = base.Equals(obj);
            }
            return(result);
        }
Exemplo n.º 7
0
 public override int GetHashCode()
 {
     return(Street1.GetHashCode());
 }
Exemplo n.º 8
0
 /// <summary>
 /// Get a hash value for the <b>Address</b> object.
 /// </summary>
 /// <returns>
 /// An integer hash value for this <b>Address</b> object.
 /// </returns>
 public override int GetHashCode()
 {
     return((Street1 == null ? 0 : Street1.GetHashCode()) ^
            (Street2 == null ? 0 : Street2.GetHashCode()) ^
            (ZipCode == null ? 0 : ZipCode.GetHashCode()));
 }
Exemplo n.º 9
0
        // Validators
        private bool CheckAddress()
        {
            // Invalid characters
            Regex nonAlphaNumeric = new Regex(@"^[a-zA-Z0-9_]+$");
            // TODO re-examine RegEx as means of validating CheckAddress() characters

            // Default state is true, updated if either address 1 or 2 fails validation
            bool isReady = true;

            // Street1
            if (regex1.IsMatch(Street1))
            {
                string[] myStreet1 = Regex.Split(Street1);

                Street1 = null;

                for (int i = 0; i < myStreet1.Length; i++)
                {
                    Street1 += myStreet1[i];
                }

                // Fail street 1 validation if less than 3 characters or consists only of numbers
                if (Street1.Length < 3 || !Street1.Contains("[a-zA-Z]"))
                {
                    Console.WriteLine("Fail on Employer Street Address 1 validation.");
                    isReady = false;
                }
            }

            // Street2
            if (regex1.IsMatch(Street2))
            {
                string[] myStreet2 = Regex.Split(Street2);
                Street2 = null;

                for (int i = 0; i < myStreet2.Length; i++)
                {
                    Street2 += myStreet2[i];
                }

                // Fail street 2 validation if less than 3 characters or consists only of numbers
                if (Street2.Length < 3 || !Street2.Contains("[a-zA-Z]"))
                {
                    Console.WriteLine("Fail on Employer Street Address 2 validation.");
                    isReady = false;
                }
            }

            // City
            if (regex1.IsMatch(City))
            {
                string[] myCity = Regex.Split(City);
                City = null;

                for (int i = 0; i < myCity.Length; i++)
                {
                    City += myCity[i];
                }

                // Fail city validation if consists only of numbers
                if (!City.Contains("[a-zA-Z]"))
                {
                    Console.WriteLine("Fail on Employer City validation.");
                    isReady = false;
                }

                return(isReady);
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// Returns true if MediumCharacteristic instances are equal
        /// </summary>
        /// <param name="other">Instance of MediumCharacteristic to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(MediumCharacteristic other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     City == other.City ||
                     City != null &&
                     City.Equals(other.City)
                     ) &&
                 (
                     Country == other.Country ||
                     Country != null &&
                     Country.Equals(other.Country)
                 ) &&
                 (
                     EmailAddress == other.EmailAddress ||
                     EmailAddress != null &&
                     EmailAddress.Equals(other.EmailAddress)
                 ) &&
                 (
                     FaxNumber == other.FaxNumber ||
                     FaxNumber != null &&
                     FaxNumber.Equals(other.FaxNumber)
                 ) &&
                 (
                     PhoneNumber == other.PhoneNumber ||
                     PhoneNumber != null &&
                     PhoneNumber.Equals(other.PhoneNumber)
                 ) &&
                 (
                     PostCode == other.PostCode ||
                     PostCode != null &&
                     PostCode.Equals(other.PostCode)
                 ) &&
                 (
                     StateOrProvince == other.StateOrProvince ||
                     StateOrProvince != null &&
                     StateOrProvince.Equals(other.StateOrProvince)
                 ) &&
                 (
                     Street1 == other.Street1 ||
                     Street1 != null &&
                     Street1.Equals(other.Street1)
                 ) &&
                 (
                     Street2 == other.Street2 ||
                     Street2 != null &&
                     Street2.Equals(other.Street2)
                 ) &&
                 (
                     MediumCharacteristicType == other.MediumCharacteristicType ||
                     MediumCharacteristicType != null &&
                     MediumCharacteristicType.Equals(other.MediumCharacteristicType)
                 ));
        }