public static IAnalyzeControl GetControl(AddressTypeEnum addressType)
        {
            switch (addressType)
            {
            case AddressTypeEnum.NONE:
                return(null);

            case AddressTypeEnum.COUNTRY:
                break;

            case AddressTypeEnum.PROVINCE:
                break;

            case AddressTypeEnum.CITY:
                break;

            case AddressTypeEnum.DISTRICT:
                return(new AnalyzeControlDistrict());

            default:
                break;
            }


            return(null);
        }
        //        [InlineData(StreetAddressTypeEnum.Both, AddressTypeEnum.Postal, "street", "pobox", "11D495DE-E1E7-4B57-BC86-20A87BA83324")]
        //        [InlineData(StreetAddressTypeEnum.Both, AddressTypeEnum.Visiting, "street", "", "11D495DE-E1E7-4B57-BC86-20A87BA83324")]
        //        [InlineData(StreetAddressTypeEnum.Both, AddressTypeEnum.Postal, "", "pobox", "11D495DE-E1E7-4B57-BC86-20A87BA83324")]
        //        [InlineData(StreetAddressTypeEnum.Both, AddressTypeEnum.Visiting, "", "", "11D495DE-E1E7-4B57-BC86-20A87BA83324")]
        public void TranslateAddress(AddressTypeEnum type, AddressCharacterEnum addressCharacter, string street, string pobox, string postalCodeId)
        {
            var model = CreateModel();

            model.AddressCharacter = addressCharacter;
            model.StreetType       = type.ToString();
            //            model.Street = street;
            var poBox = new Dictionary <string, string>();

            poBox.Add(LanguageCode.fi.ToString(), pobox);
            model.PoBox      = poBox;
            model.PostalCode = string.IsNullOrEmpty(postalCodeId)
                ? null
                : new VmPostalCode {
                Id = postalCodeId.ParseToGuid() ?? Guid.Empty
            };

            var toTranslate = new List <VmAddressSimple>()
            {
                model
            };

            var translations = RunTranslationModelToEntityTest <VmAddressSimple, Address>(translators, toTranslate, unitOfWorkMock);
            var translation  = translations.First();

            Assert.Equal(toTranslate.Count, translations.Count);
            CheckTranslation(model, translation, type);
        }
Beispiel #3
0
 private void IndicateAddressUsed(LadderProgram program, AddressTypeEnum addressType)
 {
     CleanUsedIndication();
     foreach (Line line in program.Lines)
     {
         line.Instructions.AddRange(line.Outputs);
         foreach (Instruction instruction in line.Instructions)
         {
             switch (instruction.OpCode)
             {
             /// TODO: Why this is this way?
             case OperationCode.NormallyOpenContact:
             case OperationCode.NormallyClosedContact:
             case OperationCode.OutputCoil:
             case OperationCode.Timer:
             case OperationCode.Counter:
             case OperationCode.Reset:
                 if (instruction.IsAllOperandsOk())
                 {
                     Address address = (Address)instruction.GetOperand(0);
                     if (address.AddressType == addressType)
                     {
                         address.Used = true;
                     }
                 }
                 break;
             }
         }
         line.Instructions.RemoveRange(line.Instructions.Count - line.Outputs.Count, line.Outputs.Count);
     }
 }
Beispiel #4
0
 private AddressType(AddressTypeEnum @enum)
 {
     AddressTypeID = (int)@enum;
     Name          = @enum.ToString();
     ModifiedDate  = DateTime.Now;
     rowguid       = new Guid();
     //this.People = new HashSet<Person>();
 }
        public List <int> GetAddressesIdsByAddressType(AddressTypeEnum addressType)
        {
            var db = GetDatabaseConnection();

            return(db.adr__Ewid.FindAll(db.adr__Ewid.adr_TypAdresu == addressType)
                   .Select(db.adr__Ewid.adr_Id)
                   .ToScalarList <int>());
        }
Beispiel #6
0
        private void CreateAccountAddress(
            IOrganizationService organizationService
            , ITracingService tracingService
            , Guid accountId
            , AccountKonturFocusModel accountData
            , AccountTypeEnum accountType
            , AddressTypeEnum addressType
            )
        {
            tracingService.Trace("enter konturfocussynchronizationplugin.createaccountaddress");
            ParsedAddressRF addressObj = null;

            if (accountData.UL != null)
            {
                addressObj = accountData.UL.legalAddress?.parsedAddressRF;
            }

            if (accountData.IP != null)
            {
                addressObj = accountData.IP.legalAddress?.parsedAddressRF;
            }

            if (addressObj == null)
            {
                if (accountType == AccountTypeEnum.IP && accountData != null)
                {
                    ParsedAddressRF shortenedAddress = accountData.IP?.shortenedAddress;
                    if (shortenedAddress == null)
                    {
                        return;
                    }
                    addressObj = shortenedAddress;
                }
                else
                {
                    return;
                }
            }

            CustomerAddress customerAddress = new CustomerAddress
            {
                Line1    = GetAddressLine(addressObj, accountData, accountType, addressType, tracingService),
                ParentId = new EntityReference(Account.EntityLogicalName, accountId)
            };

            customerAddress.Id = organizationService.Create(customerAddress);

            Account account = new Account
            {
                Id = accountId
            };

            FillAddress(account, tracingService, accountData, accountType, addressType);

            organizationService.Update(account);
            tracingService.Trace("exit konturfocussynchronizationplugin.createaccountaddress");
        }
Beispiel #7
0
 public static AddressTypeLookup GetAddressTypeLookup(AddressTypeEnum addressTypeEnum)
 {
     return(new AddressTypeLookup
     {
         Id = (int)addressTypeEnum,
         AddressTypeId = (int)addressTypeEnum,
         Name = AddressTypeName.FromString(addressTypeEnum.ToString()),
         Desc = addressTypeEnum + " Description"
     });
 }
Beispiel #8
0
        public bool IsAddressValid(Address address, AddressTypeEnum addressType)
        {
            // You can change this class to AddressVerifierFactory to generate a class based on addressType, etc.
            // or simply say the following
            switch (addressType)
            {
            case AddressTypeEnum.Customer:
                // Customer address check
                break;

            case AddressTypeEnum.Employee:
            // Employee..
            default:
                throw new InvalidOperationException();
            }
            return(true);
        }
Beispiel #9
0
        public bool IsAddressValid(Address address, AddressTypeEnum addressType)
        {
            switch (addressType)
            {
            case AddressTypeEnum.Customer:
                Console.WriteLine("Customer address is valid");
                break;

            case AddressTypeEnum.Employee:
                Console.WriteLine("Employee address is valid");
                break;

            default:
                throw new InvalidOperationException();
            }
            return(true);
        }
Beispiel #10
0
        public bool IsAddressValid(Address address, AddressTypeEnum addressType)
        {
            // addressType, vb. Tabanlı bir sınıf oluşturmak için bu sınıfı AddressVerifierFactory olarak değiştirebilirsiniz.
            // veya sadece şunu söyleyin
            switch (addressType)
            {
            case AddressTypeEnum.Employee:
                break;

            case AddressTypeEnum.Custemer:
                break;

            default:
                break;
            }
            return(true);
        }
        public static String GetDisplayPrefix(this AddressTypeEnum addressType)
        {
            switch (addressType)
            {
            case AddressTypeEnum.DigitalInput:
                return("I");

            case AddressTypeEnum.DigitalOutput:
                return("O");

            case AddressTypeEnum.DigitalMemory:
            case AddressTypeEnum.DigitalMemoryTimer:
            case AddressTypeEnum.DigitalMemoryCounter:
                return(GetInternalPrefix(addressType));

            default:
                return("ERROR");
            }
        }
Beispiel #12
0
        public static TModel CreateAddressVm <TModel>(AddressTypeEnum addressType)
            where TModel : IV7VmOpenApiAddressInVersionBase, new()
        {
            var vm = new TModel()
            {
                Type    = AddressCharacterEnum.Postal.ToString(),
                SubType = addressType.ToString(),
                Country = LanguageCode.fi.ToString(),
            };

            switch (addressType)
            {
            case AddressTypeEnum.Street:
                vm.StreetAddress = new VmOpenApiAddressStreetWithCoordinatesIn
                {
                    Street                = CreateLanguageItemList(),
                    StreetNumber          = "1",
                    PostalCode            = POSTAL_CODE,
                    Municipality          = MUNICIPALITY,
                    AdditionalInformation = CreateLanguageItemList()
                };
                break;

            case AddressTypeEnum.PostOfficeBox:
                vm.PostOfficeBoxAddress = new VmOpenApiAddressPostOfficeBoxIn
                {
                    PostOfficeBox         = CreateLanguageItemList(),
                    PostalCode            = POSTAL_CODE,
                    Municipality          = MUNICIPALITY,
                    AdditionalInformation = CreateLanguageItemList()
                };
                break;

            case AddressTypeEnum.Foreign:
                vm.ForeignAddress = CreateLanguageItemList();
                break;

            default:
                break;
            }

            return(vm);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="AdditionalAddress" /> class.
        /// </summary>
        /// <param name="address">address (required).</param>
        /// <param name="addressType">addressType (required).</param>
        public AdditionalAddress(Address address = default(Address), AddressTypeEnum addressType = default(AddressTypeEnum))
        {
            // to ensure "address" is required (not null)
            if (address == null)
            {
                throw new InvalidDataException("address is a required property for AdditionalAddress and cannot be null");
            }
            else
            {
                this.Address = address;
            }

            // to ensure "addressType" is required (not null)
            if (addressType == null)
            {
                throw new InvalidDataException("addressType is a required property for AdditionalAddress and cannot be null");
            }
            else
            {
                this.AddressType = addressType;
            }
        }
Beispiel #14
0
        public override VmAddressSimple TranslateEntityToVm(Address entity)
        {
            AddressTypeEnum type       = GetAddressType(entity);
            var             definition = CreateEntityViewModelDefinition <VmAddressSimple>(entity)
                                         .AddPartial(i => i, o => o as VmAddressSimpleBase)
                                         .AddSimple(input => input.Id, output => output.Id)
                                         .AddNavigation(input => input.Country != null ? input.Country : null, output => output.Country)
                                         .AddCollection(input => GetCoordinates(input.Coordinates), output => output.Coordinates)
                                         .AddNavigation(input => type.ToString(), output => output.StreetType);

            switch (type)
            {
            case AddressTypeEnum.PostOfficeBox:
                definition.AddDictionary(i => i.AddressAdditionalInformations, o => o.AdditionalInformation, k => languageCache.GetByValue(k.LocalizationId));
                definition.AddPartial(i => i.AddressPostOfficeBoxes.FirstOrDefault(), o => o);
                break;

            case AddressTypeEnum.Street:
                definition.AddDictionary(i => i.AddressAdditionalInformations, o => o.AdditionalInformation, k => languageCache.GetByValue(k.LocalizationId));
                definition.AddPartial(i => i.AddressStreets.FirstOrDefault(), o => o);
                break;

            case AddressTypeEnum.Foreign:
                definition.AddPartial(i => i.AddressForeigns.FirstOrDefault(), o => o);
                break;

            case AddressTypeEnum.NoAddress:
                definition.AddDictionary(i => i.AddressAdditionalInformations, o => o.NoAddressAdditionalInformation, k => languageCache.GetByValue(k.LocalizationId)
                                         );
                break;

            default:
                break;
            }
            var model = definition.GetFinal();

            return(model);
        }
        public Address ReadAddress(ref Int32 position, LadderAddressing addressing)
        {
            //Instruction instruction = new Instruction(ReadOperationCode(position));
            Instruction instruction = InstructionFactory.createInstruction(ReadOperationCode(position));

            switch (instruction.OpCode)
            {
            case OperationCode.None:
                break;

            case OperationCode.LineEnd:
                break;

            case OperationCode.NormallyOpenContact:
            case OperationCode.NormallyClosedContact:
                AddressTypeEnum addressType = GetAddressingType(position);
                position++;
                Int32 addressIndex = ReadInteger(position);
                position++;
                return(addressingServices.Find(addressType, addressIndex));;

            case OperationCode.OutputCoil:
            case OperationCode.Reset:
                break;

            case OperationCode.ParallelBranchBegin:
            case OperationCode.ParallelBranchEnd:
            case OperationCode.ParallelBranchNext:
                break;

            case OperationCode.Counter:
                break;

            case OperationCode.Timer:
                break;
            }
            return(null);
        }
        private void CheckTranslation(VmAddressSimple source, Address target, AddressTypeEnum addressType)
        {
            target.Should().NotBe(Guid.Empty);
            switch (addressType)
            {
            case AddressTypeEnum.Street:

                target.AddressStreets.First().StreetNames.Count.Should().Be(1);
//                    target.AddressStreets.First().StreetNames.Select(x => x.Name).FirstOrDefault().Should().Be(source.Street);
                break;

            case AddressTypeEnum.PostOfficeBox:
                target.AddressPostOfficeBoxes.First().PostOfficeBoxNames.Count.Should().Be(1);
                target.AddressPostOfficeBoxes.First().PostOfficeBoxNames.Select(x => x.Name).FirstOrDefault().Should().Be(source.PoBox.Values.First());
                break;

            case AddressTypeEnum.Foreign:
                target.AddressForeigns.First().ForeignTextNames.Count.Should().Be(1);
//                    target.AddressForeigns.First().ForeignTextNames.Select(x => x.Name).FirstOrDefault().Should().Be(source.Street);
                break;
            }
            target.Country.Should().NotBeNull();
        }
        public static String GetInternalPrefix(this AddressTypeEnum addressType)
        {
            switch (addressType)
            {
            case AddressTypeEnum.DigitalInput:
                return("P");

            case AddressTypeEnum.DigitalOutput:
                return("P");

            case AddressTypeEnum.DigitalMemory:
                return("M");

            case AddressTypeEnum.DigitalMemoryTimer:
                return("T");

            case AddressTypeEnum.DigitalMemoryCounter:
                return("C");

            default:
                return("ERROR");
            }
        }
Beispiel #18
0
        private TreeNodeCollection GetAddressingNodesByAddressType(AddressTypeEnum type)
        {
            switch (type)
            {
            case AddressTypeEnum.DigitalInput:
                return(InputsNodes);

            case AddressTypeEnum.DigitalOutput:
                return(OutputsNodes);

            case AddressTypeEnum.DigitalMemory:
                return(MemoriesNodes);

            case AddressTypeEnum.DigitalMemoryCounter:
                return(CountersNodes);

            case AddressTypeEnum.DigitalMemoryTimer:
                return(TimersNodes);

            default:
                return(null);
            }
        }
Beispiel #19
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DoEmailLookupResponse" /> class.
 /// </summary>
 /// <param name="address">The email address passed to the call. (required).</param>
 /// <param name="status">The email is &#x60;valid&#x60; or &#x60;invalid&#x60;. (required).</param>
 /// <param name="deliverability">The delivery status of the email address is&#x60;deliverable&#x60;, &#x60;undeliverable&#x60;  or &#x60;unknown&#x60;. (required).</param>
 /// <param name="reason">The reason why the checked email is invalid/undeliverable. (required).</param>
 /// <param name="risk">The risk score of the email is&#x60;high&#x60;, &#x60;medium&#x60;, &#x60;low&#x60; or &#x60;null&#x60;. (required).</param>
 /// <param name="addressType">The email address type (domain) is &#x60;free&#x60; or &#x60;corporate&#x60;. (required).</param>
 /// <param name="isDisposableAddress">This is be &#x60;true&#x60; if the domain is in the list of disposable email addresses, otherwise returns as &#x60;false&#x60;. (required).</param>
 /// <param name="suggestion">Null if nothing is suggested, however, if there is a potential typo in the email address, the closest suggestion is provided. (required).</param>
 /// <param name="emailRole">Checks the mailbox part of the email whether it matches a specific role type (‘admin’, ‘sales’, ‘webmaster’) (required).</param>
 /// <param name="localPart">The local part of the email address. (required).</param>
 /// <param name="domainPart">The domain part of the email address. (required).</param>
 /// <param name="exchange">Email exchange server domain name (MX record value). (required).</param>
 /// <param name="preference">MX record preference. (required).</param>
 /// <param name="isInWhiteList">&#x60;true&#x60; if the email address exists in TextMagic whitelist.  (required).</param>
 /// <param name="isInBlackList">&#x60;true&#x60; if the email address exists in TextMagic blacklist.  (required).</param>
 /// <param name="hasMx">&#x60;true&#x60; if the email address domain has an MX record.  (required).</param>
 /// <param name="hasAa">&#x60;true&#x60; if the email address domain has an A record (IPv4).  (required).</param>
 /// <param name="hasAaaa">&#x60;true&#x60; if the email address domain has an AAAA record (IPv6).  (required).</param>
 public DoEmailLookupResponse(string address = default(string), StatusEnum status = default(StatusEnum), string deliverability = default(string), string reason = default(string), RiskEnum risk = default(RiskEnum), AddressTypeEnum addressType = default(AddressTypeEnum), bool?isDisposableAddress = default(bool?), string suggestion = default(string), string emailRole = default(string), string localPart = default(string), string domainPart = default(string), string exchange = default(string), int?preference = default(int?), bool?isInWhiteList = default(bool?), bool?isInBlackList = default(bool?), bool?hasMx = default(bool?), bool?hasAa = default(bool?), bool?hasAaaa = default(bool?))
 {
     // to ensure "address" is required (not null)
     if (address == null)
     {
         throw new InvalidDataException("address is a required property for DoEmailLookupResponse and cannot be null");
     }
     else
     {
         this.Address = address;
     }
     // to ensure "status" is required (not null)
     if (status == null)
     {
         throw new InvalidDataException("status is a required property for DoEmailLookupResponse and cannot be null");
     }
     else
     {
         this.Status = status;
     }
     // to ensure "deliverability" is required (not null)
     if (deliverability == null)
     {
         throw new InvalidDataException("deliverability is a required property for DoEmailLookupResponse and cannot be null");
     }
     else
     {
         this.Deliverability = deliverability;
     }
     // to ensure "reason" is required (not null)
     if (reason == null)
     {
         throw new InvalidDataException("reason is a required property for DoEmailLookupResponse and cannot be null");
     }
     else
     {
         this.Reason = reason;
     }
     // to ensure "risk" is required (not null)
     if (risk == null)
     {
         throw new InvalidDataException("risk is a required property for DoEmailLookupResponse and cannot be null");
     }
     else
     {
         this.Risk = risk;
     }
     // to ensure "addressType" is required (not null)
     if (addressType == null)
     {
         throw new InvalidDataException("addressType is a required property for DoEmailLookupResponse and cannot be null");
     }
     else
     {
         this.AddressType = addressType;
     }
     // to ensure "isDisposableAddress" is required (not null)
     if (isDisposableAddress == null)
     {
         throw new InvalidDataException("isDisposableAddress is a required property for DoEmailLookupResponse and cannot be null");
     }
     else
     {
         this.IsDisposableAddress = isDisposableAddress;
     }
     // to ensure "suggestion" is required (not null)
     if (suggestion == null)
     {
         throw new InvalidDataException("suggestion is a required property for DoEmailLookupResponse and cannot be null");
     }
     else
     {
         this.Suggestion = suggestion;
     }
     // to ensure "emailRole" is required (not null)
     if (emailRole == null)
     {
         throw new InvalidDataException("emailRole is a required property for DoEmailLookupResponse and cannot be null");
     }
     else
     {
         this.EmailRole = emailRole;
     }
     // to ensure "localPart" is required (not null)
     if (localPart == null)
     {
         throw new InvalidDataException("localPart is a required property for DoEmailLookupResponse and cannot be null");
     }
     else
     {
         this.LocalPart = localPart;
     }
     // to ensure "domainPart" is required (not null)
     if (domainPart == null)
     {
         throw new InvalidDataException("domainPart is a required property for DoEmailLookupResponse and cannot be null");
     }
     else
     {
         this.DomainPart = domainPart;
     }
     // to ensure "exchange" is required (not null)
     if (exchange == null)
     {
         throw new InvalidDataException("exchange is a required property for DoEmailLookupResponse and cannot be null");
     }
     else
     {
         this.Exchange = exchange;
     }
     // to ensure "preference" is required (not null)
     if (preference == null)
     {
         throw new InvalidDataException("preference is a required property for DoEmailLookupResponse and cannot be null");
     }
     else
     {
         this.Preference = preference;
     }
     // to ensure "isInWhiteList" is required (not null)
     if (isInWhiteList == null)
     {
         throw new InvalidDataException("isInWhiteList is a required property for DoEmailLookupResponse and cannot be null");
     }
     else
     {
         this.IsInWhiteList = isInWhiteList;
     }
     // to ensure "isInBlackList" is required (not null)
     if (isInBlackList == null)
     {
         throw new InvalidDataException("isInBlackList is a required property for DoEmailLookupResponse and cannot be null");
     }
     else
     {
         this.IsInBlackList = isInBlackList;
     }
     // to ensure "hasMx" is required (not null)
     if (hasMx == null)
     {
         throw new InvalidDataException("hasMx is a required property for DoEmailLookupResponse and cannot be null");
     }
     else
     {
         this.HasMx = hasMx;
     }
     // to ensure "hasAa" is required (not null)
     if (hasAa == null)
     {
         throw new InvalidDataException("hasAa is a required property for DoEmailLookupResponse and cannot be null");
     }
     else
     {
         this.HasAa = hasAa;
     }
     // to ensure "hasAaaa" is required (not null)
     if (hasAaaa == null)
     {
         throw new InvalidDataException("hasAaaa is a required property for DoEmailLookupResponse and cannot be null");
     }
     else
     {
         this.HasAaaa = hasAaaa;
     }
 }
Beispiel #20
0
        public AddressDTO GetAddressForObjectByType(int objectId, AddressTypeEnum addressType)
        {
            var addressesForObjectByTypes = GetAddressForObjectByTypes(objectId, new[] { addressType });

            return(addressesForObjectByTypes.FirstOrDefault());
        }
Beispiel #21
0
 internal Address(AddressTypeEnum addressType, int index)
 {
     AddressType = addressType;
     Id          = index;
 }
        public void AddressAAA_Every_Property_Has_Get_Set_Test()
        {
            string val1 = "Some text";

            addressAAA.AddressText = val1;
            Assert.AreEqual(val1, addressAAA.AddressText);
            int val2 = 45;

            addressAAA.AddressID = val2;
            Assert.AreEqual(val2, addressAAA.AddressID);
            int val3 = 45;

            addressAAA.AddressTVItemID = val3;
            Assert.AreEqual(val3, addressAAA.AddressTVItemID);
            AddressTypeEnum val4 = (AddressTypeEnum)3;

            addressAAA.AddressType = val4;
            Assert.AreEqual(val4, addressAAA.AddressType);
            int val5 = 45;

            addressAAA.CountryTVItemID = val5;
            Assert.AreEqual(val5, addressAAA.CountryTVItemID);
            int val6 = 45;

            addressAAA.ProvinceTVItemID = val6;
            Assert.AreEqual(val6, addressAAA.ProvinceTVItemID);
            int val7 = 45;

            addressAAA.MunicipalityTVItemID = val7;
            Assert.AreEqual(val7, addressAAA.MunicipalityTVItemID);
            string val8 = "Some text";

            addressAAA.StreetName = val8;
            Assert.AreEqual(val8, addressAAA.StreetName);
            string val9 = "Some text";

            addressAAA.StreetNumber = val9;
            Assert.AreEqual(val9, addressAAA.StreetNumber);
            StreetTypeEnum val10 = (StreetTypeEnum)3;

            addressAAA.StreetType = val10;
            Assert.AreEqual(val10, addressAAA.StreetType);
            string val11 = "Some text";

            addressAAA.PostalCode = val11;
            Assert.AreEqual(val11, addressAAA.PostalCode);
            string val12 = "Some text";

            addressAAA.GoogleAddressText = val12;
            Assert.AreEqual(val12, addressAAA.GoogleAddressText);
            DateTime val13 = new DateTime(2010, 3, 4);

            addressAAA.LastUpdateDate_UTC = val13;
            Assert.AreEqual(val13, addressAAA.LastUpdateDate_UTC);
            int val14 = 45;

            addressAAA.LastUpdateContactTVItemID = val14;
            Assert.AreEqual(val14, addressAAA.LastUpdateContactTVItemID);
            bool val15 = true;

            addressAAA.HasErrors = val15;
            Assert.AreEqual(val15, addressAAA.HasErrors);
            IEnumerable <ValidationResult> val48 = new List <ValidationResult>()
            {
                new ValidationResult("First Error Message")
            }.AsEnumerable();

            addressAAA.ValidationResults = val48;
            Assert.AreEqual(val48, addressAAA.ValidationResults);
        }
Beispiel #23
0
 private void AddNewAddress(string strAddressType)
 {
     AddressTypeEnum addtype = (AddressTypeEnum)Enum.Parse(typeof(AddressTypeEnum), strAddressType);
 }
        public static bool AddAddressToContact(string address1, string address2, string city, string state, string zipCode, AddressTypeEnum addressType, DataModels.ContactCard.ContactCard contact, DataModels.Location.Country country)
        {

            try
            {
                var add = new DataModels.ContactCard.Address
                {
                    Address1 = address1,
                    Address2 = address2,
                    StateRaw = state,
                    CityRaw = city,
                    Zip = zipCode,
                    Country = country,
                    AddressType = (byte)addressType
                };

                var coords = OpenStreetMap.FindLatLongOfAddress(add.Address1, add.Address2, add.Zip, add.CityRaw, add.StateRaw, add.Country != null ? add.Country.Name : string.Empty);
                add.Coords = new System.Device.Location.GeoCoordinate();

                if (coords != null)
                {
                    add.Coords.Latitude = coords.Latitude;
                    add.Coords.Longitude = coords.Longitude;
                }
                else
                {
                    add.Coords.Latitude = 0;
                    add.Coords.Longitude = 0;
                }
                add.Coords.Altitude = 0;
                add.Coords.Course = 0;
                add.Coords.HorizontalAccuracy = 1;
                add.Coords.Speed = 0;
                add.Coords.VerticalAccuracy = 1;

                contact.Addresses.Add(add);
                return true;
            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, exception.GetType(), additionalInformation: address1 + " " + address2 + " " + city + " " + state + " " + zipCode + " " + country);
            }
            return false;
        }
 public static bool UpdateAddressToContact(string address1, string address2, string city, string state, string zipCode, AddressTypeEnum addressType, DataModels.ContactCard.ContactCard card, DataModels.Location.Country country)
 {
     try
     {
         if (card.Addresses.FirstOrDefault() != null)
             UpdateAddressToContact(address1, address2, city, state, zipCode, addressType, card.Addresses.FirstOrDefault(), country);
         else
         {
             DataModels.ContactCard.Address add = new DataModels.ContactCard.Address();
             UpdateAddressToContact(address1, address2, city, state, zipCode, addressType, add, country);
             card.Addresses.Add(add);
         } return true;
     }
     catch (Exception exception)
     {
         ErrorDatabaseManager.AddException(exception, exception.GetType());
     }
     return false;
 }
        public static bool UpdateAddressToContact(string address1, string address2, string city, string state, string zipCode, AddressTypeEnum addressType, DataModels.ContactCard.Address add, DataModels.Location.Country country)
        {
            try
            {

                add.Address1 = address1;
                add.Address2 = address2;
                add.StateRaw = state;
                add.CityRaw = city;
                add.Zip = zipCode;
                add.Country = country;
                add.AddressType = (byte)addressType;
                var coords = OpenStreetMap.FindLatLongOfAddress(add.Address1, add.Address2, add.Zip, add.CityRaw, add.StateRaw, add.Country != null ? add.Country.Name : string.Empty);
                if (coords != null)
                {
                    add.Coords = new System.Device.Location.GeoCoordinate();
                    add.Coords.Latitude = coords.Latitude;
                    add.Coords.Longitude = coords.Longitude;
                    add.Coords.Altitude = 0;
                    add.Coords.Course = 0;
                    add.Coords.HorizontalAccuracy = 1;
                    add.Coords.Speed = 0;
                    add.Coords.VerticalAccuracy = 1;
                }
                else
                {
                    add.Coords = new System.Device.Location.GeoCoordinate();
                    add.Coords.Latitude = 0.0;
                    add.Coords.Longitude = 0.0;
                    add.Coords.Altitude = 0;
                    add.Coords.Course = 0;
                    add.Coords.HorizontalAccuracy = 1;
                    add.Coords.Speed = 0;
                    add.Coords.VerticalAccuracy = 1;
                }
                return true;
            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, exception.GetType());
            }
            return false;
        }
Beispiel #27
0
        public Address Find(AddressTypeEnum addressType, int index)
        {
            Address fakeAddress = new Address(addressType, index);

            return(Find(fakeAddress));
        }
Beispiel #28
0
        public void AddressExtraB_Every_Property_Has_Get_Set_Test()
        {
            string val1 = "Some text";

            addressExtraB.AddressReportTest = val1;
            Assert.AreEqual(val1, addressExtraB.AddressReportTest);
            string val2 = "Some text";

            addressExtraB.AddressText = val2;
            Assert.AreEqual(val2, addressExtraB.AddressText);
            string val3 = "Some text";

            addressExtraB.CountryText = val3;
            Assert.AreEqual(val3, addressExtraB.CountryText);
            string val4 = "Some text";

            addressExtraB.ProvinceText = val4;
            Assert.AreEqual(val4, addressExtraB.ProvinceText);
            string val5 = "Some text";

            addressExtraB.MunicipalityText = val5;
            Assert.AreEqual(val5, addressExtraB.MunicipalityText);
            string val6 = "Some text";

            addressExtraB.LastUpdateContactText = val6;
            Assert.AreEqual(val6, addressExtraB.LastUpdateContactText);
            string val7 = "Some text";

            addressExtraB.AddressTypeText = val7;
            Assert.AreEqual(val7, addressExtraB.AddressTypeText);
            string val8 = "Some text";

            addressExtraB.StreetTypeText = val8;
            Assert.AreEqual(val8, addressExtraB.StreetTypeText);
            int val9 = 45;

            addressExtraB.AddressID = val9;
            Assert.AreEqual(val9, addressExtraB.AddressID);
            int val10 = 45;

            addressExtraB.AddressTVItemID = val10;
            Assert.AreEqual(val10, addressExtraB.AddressTVItemID);
            AddressTypeEnum val11 = (AddressTypeEnum)3;

            addressExtraB.AddressType = val11;
            Assert.AreEqual(val11, addressExtraB.AddressType);
            int val12 = 45;

            addressExtraB.CountryTVItemID = val12;
            Assert.AreEqual(val12, addressExtraB.CountryTVItemID);
            int val13 = 45;

            addressExtraB.ProvinceTVItemID = val13;
            Assert.AreEqual(val13, addressExtraB.ProvinceTVItemID);
            int val14 = 45;

            addressExtraB.MunicipalityTVItemID = val14;
            Assert.AreEqual(val14, addressExtraB.MunicipalityTVItemID);
            string val15 = "Some text";

            addressExtraB.StreetName = val15;
            Assert.AreEqual(val15, addressExtraB.StreetName);
            string val16 = "Some text";

            addressExtraB.StreetNumber = val16;
            Assert.AreEqual(val16, addressExtraB.StreetNumber);
            StreetTypeEnum val17 = (StreetTypeEnum)3;

            addressExtraB.StreetType = val17;
            Assert.AreEqual(val17, addressExtraB.StreetType);
            string val18 = "Some text";

            addressExtraB.PostalCode = val18;
            Assert.AreEqual(val18, addressExtraB.PostalCode);
            string val19 = "Some text";

            addressExtraB.GoogleAddressText = val19;
            Assert.AreEqual(val19, addressExtraB.GoogleAddressText);
            DateTime val20 = new DateTime(2010, 3, 4);

            addressExtraB.LastUpdateDate_UTC = val20;
            Assert.AreEqual(val20, addressExtraB.LastUpdateDate_UTC);
            int val21 = 45;

            addressExtraB.LastUpdateContactTVItemID = val21;
            Assert.AreEqual(val21, addressExtraB.LastUpdateContactTVItemID);
            bool val22 = true;

            addressExtraB.HasErrors = val22;
            Assert.AreEqual(val22, addressExtraB.HasErrors);
            IEnumerable <ValidationResult> val69 = new List <ValidationResult>()
            {
                new ValidationResult("First CSSPError Message")
            }.AsEnumerable();

            addressExtraB.ValidationResults = val69;
            Assert.AreEqual(val69, addressExtraB.ValidationResults);
        }
Beispiel #29
0
 protected AddressFormatAttribute(string formatString)
 {
     FormatString = formatString;
     Countries    = new string[0];
     AddressType  = AddressTypeEnum.Both;
 }
Beispiel #30
0
        private string GetAddressLine(
            ParsedAddressRF addressObj
            , AccountKonturFocusModel accountFromKonturFocus
            , AccountTypeEnum accountType
            , AddressTypeEnum addressType
            , ITracingService tracingService
            )
        {
            tracingService.Trace("enter konturfocussynchronizationplugin.getaddressline");
            if (addressObj == null)
            {
                if (accountType == AccountTypeEnum.IP)
                {
                    if (accountFromKonturFocus == null)
                    {
                        tracingService.Trace("accountfromkonturfocus is null");
                        return("");
                    }

                    ParsedAddressRF shortenedAddress = accountFromKonturFocus.IP?.shortenedAddress;
                    if (shortenedAddress == null)
                    {
                        tracingService.Trace("shortenedaddress is null");
                        return("");
                    }
                    addressObj = shortenedAddress;
                }
                else
                {
                    tracingService.Trace("accounttypeenum != ip");
                    return("");
                }
            }

            string regionValue = addressObj?.regionName?.topoValue;
            string regionTopo  = addressObj?.regionName?.topoFullName;
            string cityValue   = addressObj?.city?.topoValue;
            string cityTopo    = addressObj?.city?.topoFullName;
            string streetValue = addressObj?.street?.topoValue;
            string streetTopo  = addressObj?.street?.topoFullName;
            string houseValue  = addressObj?.house?.topoValue;
            string houseTopo   = addressObj?.house?.topoFullName;
            string bulkValue   = addressObj?.bulk?.topoValue;
            string bulkTopo    = addressObj.bulk != null ? $", {addressObj?.bulk?.topoFullName} " : string.Empty;
            string flatValue   = addressObj?.flat?.topoValue;
            string flatTopo    = addressObj.flat != null ? $", {addressObj?.flat?.topoFullName} " : string.Empty;
            string zipCode     = addressObj?.zipCode;

            if (!string.IsNullOrWhiteSpace(bulkTopo) && bulkTopo.Trim() == ",")
            {
                bulkTopo = " ";
            }

            string address1_StateOrProvince = @"";
            string address1_PostalCode      = addressObj.zipCode;

            string address1_City = $"{cityTopo} {cityValue}";

            if (!string.IsNullOrWhiteSpace(regionTopo) && regionTopo.ToUpper() == AddressMapper.CITY_TOPO)
            {
                address1_StateOrProvince = $"{regionTopo} {regionValue}";
            }
            else
            {
                address1_StateOrProvince = $"{regionValue} {regionTopo}";
            }
            if (!string.IsNullOrWhiteSpace(regionTopo) && regionTopo.ToUpper() == AddressMapper.REPUBLIC_TOPO)
            {
                address1_StateOrProvince = AddressMapper.Map(CountryPartTypeEnum.Republic, regionTopo, regionValue);
            }

            if (string.IsNullOrWhiteSpace(address1_City))
            {
                if (addressObj.district != null)
                {
                    string districtValue = addressObj?.district?.topoValue;
                    string districtTopo  = addressObj?.district?.topoFullName;

                    address1_City = $"{districtValue} {districtTopo}";
                }
                if (addressObj.settlement != null)
                {
                    string settlement = addressObj?.settlement?.topoValue;

                    if (string.IsNullOrWhiteSpace(streetValue))
                    {
                        streetValue = settlement;
                    }

                    string settlementTopo = addressObj?.settlement?.topoFullName;
                    if (string.IsNullOrWhiteSpace(streetTopo))
                    {
                        streetTopo = settlementTopo;
                    }
                }
            }
            else
            {
                if (addressObj.settlement != null)
                {
                    string settlement = addressObj?.settlement?.topoValue;

                    if (string.IsNullOrWhiteSpace(streetValue))
                    {
                        streetValue = settlement;
                    }

                    string settlementTopo = addressObj?.settlement?.topoFullName;
                    if (string.IsNullOrWhiteSpace(streetTopo))
                    {
                        streetTopo = settlementTopo;
                    }
                }
            }

            string address1_Line1 =
                $"{streetTopo} {streetValue}, {houseTopo} {houseValue}{bulkTopo}{bulkValue}{flatTopo}{flatValue}";

            if (!string.IsNullOrWhiteSpace(streetTopo) && AddressMapper.StreetTopo.Contains(streetTopo.ToUpper()))
            {
                address1_Line1 =
                    $"{streetValue} {streetTopo}, {houseTopo} {houseValue}{bulkTopo}{bulkValue}{flatTopo}{flatValue}";
            }

            if (addressType == AddressTypeEnum.Legal)
            {
                if (!string.IsNullOrWhiteSpace(address1_PostalCode))
                {
                    address1_PostalCode += ", ";
                }

                if (!string.IsNullOrWhiteSpace(address1_StateOrProvince))
                {
                    address1_StateOrProvince += ", ";
                }

                if (!string.IsNullOrWhiteSpace(address1_City))
                {
                    address1_City += ", ";
                }
            }

            string addressLine = (address1_PostalCode + address1_StateOrProvince + address1_City + address1_Line1).ToUpper().Trim();

            if (!string.IsNullOrWhiteSpace(addressLine) && addressLine.Substring(addressLine.Length - 1, 1) == ",")
            {
                addressLine = addressLine.Substring(0, addressLine.Length - 1);
            }

            tracingService.Trace("created line {0}", addressLine);
            tracingService.Trace("exit konturfocussynchronizationplugin.getaddressline");
            return(addressLine);
        }
Beispiel #31
0
        //public int AlocateMemoryAddressing(Device device, List<Address> addresses, AddressTypeEnum addressType, int numberOfAddress)
        //{
        //    int currentNumberOfAddress = addresses.Count;
        //    if ((currentNumberOfAddress == 0) || (currentNumberOfAddress < numberOfAddress))
        //    {
        //        for (int i = currentNumberOfAddress + 1; i <= numberOfAddress; i++)
        //        {
        //            addresses.Add(new Address(addressType, i, device.NumberBitsByPort));
        //        }
        //    }
        //    else if (currentNumberOfAddress > numberOfAddress)
        //    {
        //        for (int i = (currentNumberOfAddress - 1); i >= numberOfAddress; i--)
        //        {
        //            if (!addresses[i].Used)
        //            {
        //                addresses[i] = null;
        //                addresses.RemoveAt(i);
        //            }
        //            else
        //            {
        //                break;
        //            }
        //        }
        //    }
        //    return 0;
        //}

        public int AlocateAddressingMemoryAndTimerAndCounter(LadderProgram program, List <Address> addresses, AddressTypeEnum type, int numberOfAddresses)
        {
            IndicateAddressUsed(program, type);

            int currentNumberOfAddress = addresses.Count;

            if (currentNumberOfAddress == 0 || currentNumberOfAddress < numberOfAddresses)
            {
                for (int i = currentNumberOfAddress + 1; i <= numberOfAddresses; i++)
                {
                    //if (type.Equals(AddressTypeEnum.DigitalMemoryCounter))
                    //{
                    //    addresses.Add(new InternalCounter(i, program.device.NumberBitsByPort));
                    //}
                    //else
                    addresses.Add(new Address(type, i, program.device.NumberBitsByPort));
                }
            }
            else if (currentNumberOfAddress > numberOfAddresses)
            {
                for (int i = (currentNumberOfAddress - 1); i >= numberOfAddresses; i--)
                {
                    if (!addresses[i].Used)
                    {
                        addresses[i] = null;
                        addresses.RemoveAt(i);
                    }
                    else
                    {
                        break;
                    }
                }
            }
            return(0);
        }
Beispiel #32
0
 protected AddressFormatAttribute(string formatString, AddressTypeEnum addressType)
 {
     FormatString = formatString;
     Countries    = new string[0];
     AddressType  = addressType;
 }
Beispiel #33
0
 internal Address(AddressTypeEnum addressType, int index, int numberOfBitsByPort)
 {
     AddressType             = addressType;
     Id                      = index;
     this.numberOfBitsByPort = numberOfBitsByPort;
 }
        /// <summary>
        /// Parse the RecipientFlags structure.
        /// </summary>
        /// <param name="s">A stream containing the RecipientFlags structure</param>
        public override void Parse(Stream s)
        {
            base.Parse(s);
            Byte tempByte = ReadByte();
            int index = 0;
            this.R = GetBits(tempByte, index, 1);
            index = index + 1;
            this.S = GetBits(tempByte, index, 1);
            index = index + 1;
            this.T = GetBits(tempByte, index, 1);
            index = index + 1;
            this.D = GetBits(tempByte, index, 1);
            index = index + 1;
            this.E = GetBits(tempByte, index, 1);
            index = index + 1;
            this.Type = (AddressTypeEnum)GetBits(tempByte, index, 3);

            tempByte = ReadByte();
            index = 0;
            this.O = GetBits(tempByte, index, 1);
            index = index + 1;
            this.Reserved = GetBits(tempByte, index, 4);
            index = index + 4;
            this.I = GetBits(tempByte, index, 1);
            index = index + 1;
            this.U = GetBits(tempByte, index, 1);
            index = index + 1;
            this.N = GetBits(tempByte, index, 1);
        }
Beispiel #35
0
        /// <summary>
        /// adds billing information to the member contact information.
        /// </summary>
        /// <param name="memberId"></param>
        /// <param name="contact"></param>
        /// <returns></returns>
        public static bool AddContactToMember(Guid memberId, InvoiceContactInfo contact, AddressTypeEnum type)
        {
            try
            {
                var dc = new ManagementContext();
                int country = Convert.ToInt32(contact.Country);
                var mem = dc.Members.Where(x => x.MemberId == memberId).FirstOrDefault();
                if (mem.ContactCard != null && mem.ContactCard.Addresses.Count > 0)
                {
                    bool addAddress = true;
                    foreach (var address in mem.ContactCard.Addresses)
                    {
                        //checking if address exists.
                        if (address.Address1 == contact.Street && address.Address2 == contact.Street2 && address.Zip == contact.Zip)
                            addAddress = false;
                    }
                    if (addAddress)
                    {
                        ContactCard.ContactCardFactory.AddAddressToContact(contact.Street, contact.Street2, contact.City, contact.State, contact.Zip, type, mem.ContactCard, dc.Countries.Where(x => x.CountryId == country).FirstOrDefault());
                    }
                }
                else if (mem.ContactCard != null && mem.ContactCard.Addresses.Count == 0)
                {

                    ContactCard.ContactCardFactory.AddAddressToContact(contact.Street, contact.Street2, contact.City, contact.State, contact.Zip, type, mem.ContactCard, dc.Countries.Where(x => x.CountryId == country).FirstOrDefault());
                }
                else if (mem.ContactCard == null)
                {

                    mem.ContactCard = new DataModels.ContactCard.ContactCard();
                    ContactCard.ContactCardFactory.AddAddressToContact(contact.Street, contact.Street2, contact.City, contact.State, contact.Zip, type, mem.ContactCard, dc.Countries.Where(x => x.CountryId == country).FirstOrDefault());

                }
                int c = dc.SaveChanges();
                return c > 0;
            }
            catch (Exception e)
            {
                ErrorDatabaseManager.AddException(e, e.GetType(), errorGroup: ErrorGroupEnum.Database);
            }
            return false;
        }