Example #1
0
        void AddPersonToListView(IndividualClass person)
        {
            string birthAddress          = "";
            string deathAddress          = "";
            IndividualEventClass birthEv = person.GetEvent(IndividualEventClass.EventType.Birth);

            if (birthEv != null)
            {
                AddressClass address = birthEv.GetAddress();
                if (address != null)
                {
                    birthAddress = address.ToString();
                }
            }
            IndividualEventClass deathEv = person.GetEvent(IndividualEventClass.EventType.Death);

            if (deathEv != null)
            {
                AddressClass address = deathEv.GetAddress();
                if (address != null)
                {
                    deathAddress = address.ToString();
                }
            }

            ListViewItem item = new ListViewItem(person.GetName());

            item.SubItems.AddRange(new string[] { person.GetDate(IndividualEventClass.EventType.Birth).ToString(), birthAddress, person.GetDate(IndividualEventClass.EventType.Death).ToString(), deathAddress });
            item.Tag = person.GetXrefName();

            resultList.Items.Add(item);
        }
Example #2
0
        private int DetermineNumberOfSubnets(int BitsBorrowed, AddressClass Class)
        {
            // For clarity
            const int BITS_PER_SUBNET = 32;


            // Determine the number of subnets that will be needed by taking the ammount of bits in a full mask (32), then
            // subtracting it by the base ammount of bits in that subnet:
            // - Class A = 8
            // - Class B = 16
            // - Class C = 24
            // Then subtracting it by the number of bits borrowed and returning the power of it
            int bitsLeft = 0;

            switch (Class)
            {
            case AddressClass.A:
                bitsLeft = (BITS_PER_SUBNET - 8) - BitsBorrowed;
                return(IntPow(2, bitsLeft));

            case AddressClass.B:
                bitsLeft = (BITS_PER_SUBNET - 16) - BitsBorrowed;
                return(IntPow(2, bitsLeft));

            case AddressClass.C:
                bitsLeft = (BITS_PER_SUBNET - 24) - BitsBorrowed;
                return(IntPow(2, bitsLeft));

            default:
                return(-1);
            }
        }
Example #3
0
        /**
         * Gets the records from the cache that match the given domain, class
         * and type. For class and type, UNSUPPORTED are considered wildcards.
         */
        public HashSet <DNSRecord> Query(Domain domain, AddressClass cls, ResourceRecordType type)
        {
            var check_class = cls != AddressClass.UNSUPPORTED;
            var check_type  = type != ResourceRecordType.UNSUPPORTED;
            var output      = new HashSet <DNSRecord>();

            logger.Trace("Cache asked for domain {0}, class {1}, rtype {2}", domain, cls, type);

            // Avoid going over any records which are out of date
            CleanTTL();

            foreach (var record in complete_cache)
            {
                if (record.Name != domain ||
                    (check_class && record.AddressClass != cls) ||
                    (check_type && record.Resource.Type != type))
                {
                    continue;
                }

                output.Add(record);
            }

            logger.Trace("Found {0} records", output.Count);
            return(output);
        }
        IndividualEventClass DecodeEventType(string eventString, IndividualEventClass.EventType evType, bool note)
        {
            IndividualEventClass ev = new IndividualEventClass(evType);
            FamilyDateTimeClass  date;
            string tempString = eventString;

            date = ParseDateString(ref tempString);
            if (date != null)
            {
                ev.SetDate(date);
            }
            if (tempString.Length > 0)
            {
                if (note)
                {
                    ev.AddNote(new NoteClass(tempString));
                }
                else
                {
                    AddressClass address = new AddressClass();
                    address.AddAddressPart(AddressPartClass.AddressPartType.StreetAddress, tempString);
                    ev.AddAddress(address);
                }
            }
            trace.TraceInformation(evType + ":" + eventString + " => " + tempString + " " + ev);
            return(ev);
        }
Example #5
0
 public DNSRecord(Domain name, AddressClass address_class, UInt32 ttl, IDNSResource resource)
 {
     Name         = name;
     AddressClass = address_class;
     TimeToLive   = ttl;
     Resource     = resource;
 }
Example #6
0
        public static EmployeeClass getEmployee()
        {
            EmployeeClass emp = new EmployeeClass();

            emp.Name              = "Mary";
            emp.Salary            = 4500;
            emp.DeptNo            = 30;
            emp.Comm              = 250;
            emp.HireDate          = Convert.ToDateTime("11-11-2016");
            emp.Empno             = 4321;
            emp.dept.Deptname     = "Accounting";
            emp.dept.Deptlocation = "New york";
            AddressClass add1 = new AddressClass();

            add1.City        = "Manassas";
            add1.Street      = "7354 Wichita Ct";
            add1.Zipcode     = 22012;
            add1.AddressNo   = 1;
            add1.state1.Id   = 1;
            add1.state1.Code = "VA";
            add1.state1.Name = "Virginia";
            AddressClass add2 = new AddressClass();

            add2.City        = "Chantilly";
            add2.Street      = "4222 MSudley Rd";
            add2.Zipcode     = 20152;
            add2.AddressNo   = 2;
            add2.state1.Id   = 2;
            add2.state1.Code = "MD";
            add2.state1.Name = "Maryland";
            emp.Addresses.Add(add1);
            emp.Addresses.Add(add2);
            return(emp);
        }
Example #7
0
        private List <NodeButton> returnNodesTowardsDestination(AddressClass destination)
        {
            int x1 = this.nodeAddress.x;
            int y1 = this.nodeAddress.y;

            int x2 = destination.x;
            int y2 = destination.y;

            double currentNodeDistance = Math.Sqrt(Math.Pow(x2 - x1, 2) + Math.Pow(y2 - y1, 2));

            Console.WriteLine("Current Distance :" + currentNodeDistance + " Of Node: " + this.nodeID);

            List <NodeButton> towardsDestination = new List <NodeButton>();

            foreach (NodeButton node in this.neighbouringNodes)
            {
                int x3 = node.nodeAddress.x;
                int y3 = node.nodeAddress.y;

                double dist = Math.Sqrt(Math.Pow(x2 - x3, 2) + Math.Pow(y2 - y3, 2));
                Console.WriteLine("Neighbour Distance :" + dist + " Of Node: " + node.nodeID);

                if (dist <= currentNodeDistance)
                {
                    towardsDestination.Add(node);
                }
            }

            return(towardsDestination);
        }
Example #8
0
		public AddAddressPage (AddressClass address, RootPage parent)
		{
			InitializeComponent ();
			mParent = parent;

			mAddressModel = address;

			
			NavigationPage.SetHasNavigationBar (this, false);
			InitializeLayout ();

			if (address != null) {
				SetInitialTexts ();
				bNameTextChanged = true;
				bSurNameTextChanged = true;
				bAddressTextChanged = true;
				bRegionTextChanged = true;
				bAddressDescriptionTextChanged = true;
				bAdressLine3TextChanged = true;
				bTelephoneTextChanged = true;
				SetSubmitButton ();
			}

			EventHandlers ();
		}
        public void AddAddressToCustomer(AddressClass address, CustomerClass customer)
        {
            Customer cust = _db.Customer.Include(c => c.CustomerAddress).First(c => c.Username == customer.Username);

            address.StoreID = _db.Store.Where(s => s.Zip == address.Zip).First().StoreId;
            cust.CustomerAddress.Add(Map(address));
            Save();
        }
Example #10
0
        /// <summary>
        /// 保存addressdata数据集数据
        /// </summary>
        /// <param name="addressdata">数据集对象</param>
        /// <returns>返回保存后的响应信息</returns>
        public String SaveAddress(AddressData addressdata)
        {
            #region
            AddressClass addressclass = new AddressClass();
            return(base.Save(addressdata, addressclass));

            #endregion
        }
Example #11
0
        public DNSQuestion(Domain name, ResourceRecordType type, AddressClass address_class)
        {
            Name         = name;
            QueryType    = type.Normalize();
            AddressClass = address_class.Normalize();

            raw_query_type    = type;
            raw_address_class = address_class;
        }
Example #12
0
 public PacketClass(AddressClass destinationAddress, AddressClass sourceAddress,
                    AddressClass originAddress, String message, PacketType packetType)
 {
     this.destinationAddress = destinationAddress;
     this.sourceAddress      = sourceAddress;
     this.originAddress      = originAddress;
     this.message            = message;
     this.packetType         = packetType;
 }
        public Person(string firstName, string lastName, string city, string street)
        {
            FirstName = firstName;
            LastName  = lastName;

            Address        = new AddressClass();
            Address.City   = city;
            Address.Street = street;
        }
Example #14
0
        public static AddressClass Normalize(this AddressClass address)
        {
            switch (address)
            {
            case AddressClass.INTERNET:
                return(address);

            default:
                return(AddressClass.UNSUPPORTED);
            }
        }
Example #15
0
        /// <summary>
        /// Uses the ammount of bits bowrowed to determine the subnetmask
        /// </summary>
        /// <returns></returns>
        private SubnetMask GetSubnetAddress(AddressClass AddrClass, int BitsBorrowed, int AddressBits)
        {
            // Use the address class to determine what the defaul subnet mask is
            byte[] BaseAddress;

            // Builts a base subnet with the address class
            switch (AddrClass)
            {
            case AddressClass.A:
                BaseAddress = new byte[] { 255, 0, 0, 0 };
                break;

            case AddressClass.B:
                BaseAddress = new byte[] { 255, 255, 0, 0 };
                break;

            case AddressClass.C:
                BaseAddress = new byte[] { 255, 255, 255, 0 };
                break;

            default:
                BaseAddress = new byte[] { 255, 255, 255, 0 };
                break;
            }

            int FirstIndexOfZero = Array.IndexOf(BaseAddress, 0);

            // Get local resource dictionary
            var assembly = typeof(IpAddress).GetTypeInfo().Assembly;

            string[] Resources = assembly.GetManifestResourceNames();

            // Load resources based on address class
            Stream       fileStream = assembly.GetManifestResourceStream("Network.SubnetData." + AddrClass.ToString() + ".json");
            StreamReader Reader     = new StreamReader(fileStream);

            // Parse json from resources
            string  contents = Reader.ReadToEnd();
            dynamic JsonData = JsonConvert.DeserializeObject(contents);

            // Determine Address class
            string AddressString = "";

            AddressString = JsonData[BitsBorrowed.ToString()];

            // Build the subnet mask object that will contain the nessecary information to build the addressing scheme
            SubnetMask ReturnAddress = new SubnetMask(AddressString);

            ReturnAddress.BitsBorrowed         = BitsBorrowed;
            ReturnAddress.UsableHostsPerSubnet = AddressesPerSubnet(AddressBits);
            ReturnAddress.AddressesPerSubnet   = IntPow(2, BitsBorrowed);

            return(ReturnAddress);
        }
Example #16
0
        private string CreateToolString()
        {
            string str = xref + "\n";

            if (family != null)
            {
                IndividualEventClass ev = family.GetEvent(IndividualEventClass.EventType.FamMarriage);

                if (ev != null)
                {
                    str += "Married ";

                    FamilyDateTimeClass date = ev.GetDate();

                    if ((date != null) && (date.GetDateType() != FamilyDateTimeClass.FamilyDateType.Unknown))
                    {
                        str += date.ToString();
                    }
                    AddressClass address = ev.GetAddress();
                    if (address != null)
                    {
                        str += " in " + address.ToString();
                    }
                    else
                    {
                        PlaceStructureClass place = ev.GetPlace();

                        if (place != null)
                        {
                            str += " in " + place.ToString();
                        }
                    }
                    str += "\n";
                }
                IList <IndividualXrefClass> childList = family.GetChildList();
                int children = 0;

                if (childList != null)
                {
                    children = childList.Count;
                }
                IList <IndividualXrefClass> parentList = family.GetParentList();
                int parents = 0;

                if (parentList != null)
                {
                    parents = parentList.Count;
                }
                str += parents + " parents and " + children + " children";
            }

            return(str);
        }
Example #17
0
        private static Company InitCompany()
        {
            var city = new City
            {
                CountryId = "3123456789",
                Id        = "123654789",
                Name      = "Haifa",
                RegionId  = "2"
            };
            var region = new Region {
                CountryId = "3123456789", Id = "24682468", Name = "North"
            };
            var address = new AddressClass
            {
                City       = city,
                Country    = "3123456789",
                Region     = region,
                Line1      = "Ilnot",
                Line2      = "21",
                PostalCode = 12345
            };
            var contact = new ContactClass
            {
                Name  = "abcdefghi",
                Title = "jklmnopqrst"
            };

            var employees = new Employee[10];

            for (var i = 0; i < 10; i++)
            {
                employees[i] = new Employee
                {
                    Id        = "aaaa",
                    FirstName = "bbbb",
                    LastName  = "cccc"
                };
            }

            var company = new Company
            {
                Address      = address,
                Name         = "Hibernating Rhinos",
                Contact      = contact,
                EmployeesIds = employees,
                Phone        = "054111222",
                ExternalId   = "123123123",
                Fax          = "456456456",
                Type         = Company.CompanyType.Public
            };

            return(company);
        }
        public void RemoveCustomerAddress(AddressClass address, CustomerClass customer)
        {
            int addID = _db.CustomerAddress.Where(a => a.Street == address.Street && a.State == address.State).First().CustomerAddressId;
            List <PizzaOrder> OldOrderList = _db.PizzaOrder.Where(o => o.CustomerAddressId == addID).ToList();

            foreach (var order in OldOrderList)
            {
                order.CustomerAddressId = 1; // one is the "deleted customer address" value
            }
            _db.Remove(_db.CustomerAddress.Where(ca => ca.Customer.Username == customer.Username && ca.Street == address.Street));
            Save();
        }
Example #19
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            AddressClass add1 = new AddressClass();

            add1.Street = txtStreet.Text;
            add1.City   = txtCity.Text;

            add1.Zipcode = Convert.ToInt32(txtZipcode.Text);

            addresses.Add(add1);
            Session["Address"] = addresses;
            // EmployeeClass emp1 = (EmployeeClass)Session["Emp"];
        }
 internal static CustomerAddress Map(AddressClass address)
 {
     return(new CustomerAddress
     {
         CustomerAddressId = address.AddressID,
         CustomerId = address.CustomerID,
         StoreId = address.StoreID,
         Street = address.Street,
         Street2 = address.Apartment,
         City = address.City,
         State = address.State,
         Zip = address.Zip
     });
 }
Example #21
0
        public NodeButton findNextNode(AddressClass destinationAddress)
        {
            int x1 = this.nodeAddress.x;
            int y1 = this.nodeAddress.y;

            int x2 = destinationAddress.x;
            int y2 = destinationAddress.y;

            NodeButton closestNode = null;

            double            distance           = -1;
            List <NodeButton> towardsDestination = returnNodesTowardsDestination(destinationAddress);

            foreach (NodeButton node in towardsDestination)
            {
                AddressClass nodeAddress = node.nodeAddress;

                double x0 = nodeAddress.x;
                double y0 = nodeAddress.y;

                double x2_x1 = x2 - x1;
                double y1_y0 = y1 - y0;

                double x1_x0 = x1 - x0;
                double y2_y1 = y2 - y1;

                double numerator = System.Math.Abs(x2_x1 * y1_y0 - x1_x0 * y2_y1);

                double denominator = System.Math.Sqrt(x2_x1 * x2_x1 + y2_y1 * y2_y1);

                double tempDistance = numerator / denominator;

                if (distance == -1)
                {
                    closestNode = node;
                    distance    = tempDistance;
                }
                else if (tempDistance < distance)
                {
                    closestNode = node;
                    distance    = tempDistance;
                }
            }

            Console.WriteLine("Least Distance: " + distance);
            return(closestNode);
        }
Example #22
0
        private int DetermineBitsForAddressSpace(int BitsBorrowed, AddressClass Class)
        {
            switch (Class)
            {
            case AddressClass.A:
                return(24 - BitsBorrowed);

            case AddressClass.B:
                return(16 - BitsBorrowed);

            case AddressClass.C:
                return(8 - BitsBorrowed);

            default:
                return(-1);
            }
        }
Example #23
0
 internal static AddressUI Map(AddressClass address)
 {
     if (address == null)
     {
         return(null);
     }
     return(new AddressUI()
     {
         Street = address.Street,
         Apartment = address.Apartment,
         City = address.City,
         Zip = address.Zip,
         State = address.State,
         AddressID = address.AddressID,
         StoreID = address.StoreID,
         CustomerID = address.CustomerID
     });
 }
Example #24
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Application["AddressFinder"] = null;

        if (Application["AddressFinder"] == null)
        {
            string path = Server.MapPath("App_Data/Addresses.csv");
            using (StreamReader readfile = new StreamReader(path))
            {
                string line;
                while ((line = readfile.ReadLine()) != null)
                {
                    AddressClass address = new AddressClass(line);
                    addrList.Add(address);
                }
            }

            addrList.Sort();
            Application["AddressFinder"] = addrList;

            createLinks();
            
            //addrLabel.Text = "";

        }

        else
        {
            addrList = (List<AddressClass>)Application["addrList"];
            createLinks();
            people.Items.Insert(0, "Select Name");
            //addrLabel.Text = "";
        }

        if (IsPostBack)
        {
            return;
        }

        people.Items.Insert(0, "Select Name");
        addrLabel.Enabled = false;

    }
Example #25
0
        //Initialize NodeButton with parameters
        public NodeButton(int nodeID, AddressClass nodeAddress, Panel routingPanel)
        {
            this.nodeID       = nodeID;
            this.nodeAddress  = nodeAddress;
            this.drawingPanel = routingPanel;
            this.Location     = new Point(nodeAddress.x, nodeAddress.y);
            this.Size         = new Size(50, 50);
            this.FlatStyle    = FlatStyle.Flat;
            this.BackColor    = Color.Transparent;
            this.FlatAppearance.BorderSize = 0;
            this.TextImageRelation         = TextImageRelation.ImageAboveText;

            //Set random image from ImageList
            int imageIndex = GlobalVariable.RandomNumber(0, 4);

            this.Image = GlobalVariable.imageList[imageIndex];

            routingPanel.Controls.Add(this);
        }
Example #26
0
        /**
         * Tries to resolve a question against the cache, and possibly several
         * servers. Throws a ResolverException if both methods fail.
         */
        public DNSPacket QueryServers(Domain domain, ResourceRecordType record_kind, AddressClass addr_class, EndPoint[] servers)
        {
            var question = new DNSQuestion(domain, record_kind, addr_class);

            foreach (var server in servers)
            {
                try
                {
                    var response = send_query(server, question, true);
                    if (response.ResponseType == ResponseType.NO_ERROR)
                    {
                        logger.Trace("Accepting response {0} from {1}", response, server);
                        return(response);
                    }
                }
                catch (SocketException error)
                {
                    logger.Trace("Recoverable error: " + error);
                }
            }

            throw new ResolverException(question.Name, "Cannot resolve query " + question);
        }
Example #27
0
        /**
         * Resolves the given query, returning a QueryResult that contains
         * everything we found while doing the resolution.
         */
        public QueryResult Execute(Domain domain, ResourceRecordType rtype, AddressClass addr_class, bool recursive)
        {
            logger.Trace("Executing query on {0} for type {1} with recursion {2}",
                         domain, rtype, recursive);

            if (zone.IsAuthorityFor(domain))
            {
                var records = zone.Query(domain, rtype, addr_class).ToList();

                // It is possible that there is a CNAME that we should be aware of - in that case, check
                // it and see if we can find one.
                if (records.Count == 0)
                {
                    var cname_records = zone.Query(domain, ResourceRecordType.CANONICAL_NAME, addr_class).ToArray();

                    if (cname_records.Length != 0)
                    {
                        logger.Trace("Authoritative for CNAMEs, re-executing");

                        // In this case, try again with the alias
                        var alias         = ((CNAMEResource)cname_records[0].Resource).Alias;
                        var alias_results = Execute(alias, rtype, addr_class, recursive);

                        // The RFC directs us to return any intermediate CNAMEs, which we do
                        alias_results.Answers.InsertRange(0, cname_records);

                        return(alias_results);
                    }
                }

                var result = new QueryResult();
                result.IsAuthority = true;
                result.FoundAnswer = true;
                result.Answers     = new List <DNSRecord>();
                result.Authority   = new List <DNSRecord>();
                result.Additional  = new List <DNSRecord>();

                result.Answers.AddRange(records);
                result.Authority.Add(zone.StartOfAuthority);
                return(result);
            }
            else
            {
                var owning_subzone = zone.FindSubZone(domain);
                if (owning_subzone != null)
                {
                    logger.Trace("Subzone {0} is authoritative", owning_subzone);

                    // We can punt on the computation to our subzone delgation
                    var subzone_nameservers             = zone.Query(owning_subzone, ResourceRecordType.NAME_SERVER, addr_class);
                    var subzone_nameserver_addr_records = subzone_nameservers
                                                          .SelectMany(ns => zone.Query(ns.Name, ResourceRecordType.HOST_ADDRESS, addr_class));
                    var subzone_nameserver_addrs = subzone_nameserver_addr_records.Select(
                        record => new IPEndPoint(((AResource)record.Resource).Address, 53)
                        ).ToArray();

                    IEnumerable <DNSRecord> response = null;
                    try
                    {
                        var info = resolver.Resolve(domain, ResourceRecordType.HOST_ADDRESS, addr_class, subzone_nameserver_addrs);
                        response = info.aliases.Concat(info.answers).ToList();
                    }
                    catch (ResolverException err)
                    {
                        logger.Trace("Could not resolve from subzone: {0}", err);
                        response = new DNSRecord[] { };
                    }

                    var result = new QueryResult();
                    result.IsAuthority = false;
                    result.FoundAnswer = response.Count() > 0;
                    result.Answers     = new List <DNSRecord>(response);
                    result.Authority   = new List <DNSRecord>(subzone_nameservers);
                    result.Additional  = new List <DNSRecord>(subzone_nameserver_addr_records);
                    return(result);
                }
                else if (recursive)
                {
                    // We'll have to go outside our zone and use the general-purpose resolver
                    ResolverResult response;
                    logger.Trace("No authoritative server is local, executing recursive resolver");

                    try
                    {
                        response = resolver.Resolve(domain, rtype, addr_class, zone.Relays);
                    }
                    catch (ResolverException err)
                    {
                        logger.Trace("Could not resolve: {0}", err);

                        response                     = new ResolverResult();
                        response.answers             = new List <DNSRecord>();
                        response.aliases             = new List <DNSRecord>();
                        response.referrals           = new List <DNSRecord>();
                        response.referral_additional = new List <DNSRecord>();
                    }

                    var result = new QueryResult();
                    result.IsAuthority = false;
                    result.FoundAnswer = response.answers.Count() > 0;
                    result.Answers     = response.aliases.Concat(response.answers).ToList();
                    result.Authority   = response.referrals.ToList();
                    result.Additional  = response.referral_additional.ToList();
                    return(result);
                }
                else
                {
                    var cached_responses = cache.Query(domain, AddressClass.INTERNET, rtype);
                    if (cached_responses.Count > 0)
                    {
                        logger.Trace("Non-recursive search found {0} cached results", cached_responses.Count);

                        var cached_result = new QueryResult();
                        cached_result.IsAuthority = false;
                        cached_result.FoundAnswer = true;
                        cached_result.Answers     = cached_responses.ToList();
                        cached_result.Additional  = new List <DNSRecord>();
                        cached_result.Authority   = new List <DNSRecord>();
                        return(cached_result);
                    }

                    // If we can't recurse, and our cache knows nothing, then punt onto the forwarder
                    logger.Trace("Executing limited-case non-recursive resolver");

                    var question = new DNSQuestion(domain, rtype, AddressClass.INTERNET);

                    foreach (var forwarder in zone.Relays)
                    {
                        try
                        {
                            var forward_result = ResolverUtils.SendQuery(forwarder, question, false);

                            // If the server doesn't like our request, then pass it to something else
                            if (forward_result.ResponseType != ResponseType.NO_ERROR &&
                                forward_result.ResponseType != ResponseType.NAME_ERROR)
                            {
                                continue;
                            }

                            var forward_return = new QueryResult();
                            forward_return.FoundAnswer = forward_result.ResponseType == ResponseType.NO_ERROR;
                            forward_return.IsAuthority = false;
                            forward_return.Answers     = forward_result.Answers.ToList();
                            forward_return.Additional  = forward_result.AdditionalRecords.ToList();
                            forward_return.Authority   = forward_result.AuthoritativeAnswers.ToList();
                            return(forward_return);
                        }
                        catch (SocketException err)
                        {
                            // We can safely punt onto the next forwarder if one bails
                            logger.Trace("Could not request from {0}: {1}", forwarder, err);
                        }
                    }

                    // We can't do anything else here, so there is no such host, as far as we knot
                    var result = new QueryResult();
                    result.FoundAnswer = false;
                    result.IsAuthority = false;
                    result.Answers     = new List <DNSRecord>();
                    result.Authority   = new List <DNSRecord>();
                    result.Additional  = new List <DNSRecord>();
                    return(result);
                }
            }
        }
        /// <summary>
        /// Uses the ammount of bits bowrowed to determine the subnetmask
        /// </summary>
        /// <returns></returns>
        private SubnetMask GetSubnetAddress(AddressClass AddrClass, int BitsBorrowed, int AddressBits)
        {
            // Use the address class to determine what the defaul subnet mask is
            byte[] BaseAddress;

            // Builts a base subnet with the address class
            switch (AddrClass)
            {
                case AddressClass.A:
                    BaseAddress = new byte[] { 255, 0, 0, 0 };
                    break;
                case AddressClass.B:
                    BaseAddress = new byte[] { 255, 255, 0, 0 };
                    break;
                case AddressClass.C:
                    BaseAddress = new byte[] { 255, 255, 255, 0 };
                    break;
                default:
                    BaseAddress = new byte[] { 255, 255, 255, 0 };
                    break;
            }

            int FirstIndexOfZero = Array.IndexOf(BaseAddress, 0);

            // Get local resource dictionary
            var assembly = typeof(IpAddress).GetTypeInfo().Assembly;
            string[] Resources = assembly.GetManifestResourceNames();

            // Load resources based on address class
            Stream fileStream = assembly.GetManifestResourceStream("Network.SubnetData." + AddrClass.ToString() + ".json");
            StreamReader Reader = new StreamReader(fileStream);

            // Parse json from resources
            string contents = Reader.ReadToEnd();
            dynamic JsonData = JsonConvert.DeserializeObject(contents);

            // Determine Address class
            string AddressString = "";
            AddressString = JsonData[BitsBorrowed.ToString()];

            // Build the subnet mask object that will contain the nessecary information to build the addressing scheme
            SubnetMask ReturnAddress = new SubnetMask(AddressString);
            ReturnAddress.BitsBorrowed = BitsBorrowed;
            ReturnAddress.UsableHostsPerSubnet = AddressesPerSubnet(AddressBits);
            ReturnAddress.AddressesPerSubnet = IntPow(2, BitsBorrowed);

            return ReturnAddress;
        }
        private int DetermineNumberOfSubnets(int BitsBorrowed, AddressClass Class)
        {
            // For clarity
            const int BITS_PER_SUBNET = 32;

            // Determine the number of subnets that will be needed by taking the ammount of bits in a full mask (32), then
            // subtracting it by the base ammount of bits in that subnet:
            // - Class A = 8
            // - Class B = 16
            // - Class C = 24
            // Then subtracting it by the number of bits borrowed and returning the power of it
            int bitsLeft = 0;

            switch (Class)
            {
                case AddressClass.A:
                    bitsLeft = (BITS_PER_SUBNET - 8) - BitsBorrowed;
                    return IntPow(2, bitsLeft);
                case AddressClass.B:
                    bitsLeft = (BITS_PER_SUBNET - 16) - BitsBorrowed;
                    return IntPow(2, bitsLeft);
                case AddressClass.C:
                    bitsLeft = (BITS_PER_SUBNET - 24) - BitsBorrowed;
                    return IntPow(2, bitsLeft);
                default:
                    return -1;
            }
        }
 private int DetermineBitsForAddressSpace(int BitsBorrowed, AddressClass Class)
 {
     switch (Class)
     {
         case AddressClass.A:
             return 24 - BitsBorrowed;
         case AddressClass.B:
             return 16 - BitsBorrowed;
         case AddressClass.C:
             return 8 - BitsBorrowed;
         default:
             return -1;
     }
 }
Example #31
0
        public AddressCell(AddressClass address, SettingsPage rootPage)
        {
            mRootPage = rootPage;
            mAddressClass = address;

            var mainLayout = new RelativeLayout () {
                WidthRequest = MyDevice.GetScaledSize(600),
                HeightRequest = MyDevice.GetScaledSize(122),
                Padding = 0
            };

            var backgroundImage = new CachedImage () {
                WidthRequest = MyDevice.GetScaledSize(600),
                HeightRequest = MyDevice.GetScaledSize(122),
                CacheDuration = TimeSpan.FromDays(30),
                DownsampleToViewSize = true,
                RetryCount = 10,
                RetryDelay = 250,
                TransparencyEnabled = false,
                FadeAnimationEnabled = false,
                Source = "SettingsPage_AddressCellBackground.png"
            };

            var editButton = new Label () {
                WidthRequest = MyDevice.GetScaledSize (48),
                HeightRequest = MyDevice.GetScaledSize(68),
                HorizontalTextAlignment = TextAlignment.Center,
                VerticalTextAlignment = TextAlignment.End,
                TextColor = Color.FromRgb(98,98,98),
                Text = "edit",
                FontSize = MyDevice.FontSizeMicro
            };

            mActiveAddressImage = new RelativeLayout () {
                WidthRequest = MyDevice.GetScaledSize(82),
                HeightRequest = MyDevice.GetScaledSize(90),
                BackgroundColor = Color.White
            };

            var nameLabel = new Label () {
                WidthRequest = MyDevice.GetScaledSize (300),
                HeightRequest = MyDevice.GetScaledSize(28),
                HorizontalTextAlignment = TextAlignment.Start,
                VerticalTextAlignment = TextAlignment.Center,
                TextColor = Color.FromRgb(98,98,98),
                Text = address.Name,
                FontSize = MyDevice.FontSizeSmall
            };

            var addressLabel = new Label () {
                WidthRequest = MyDevice.GetScaledSize (360),
                HeightRequest = MyDevice.GetScaledSize(28),
                HorizontalTextAlignment = TextAlignment.Start,
                VerticalTextAlignment = TextAlignment.Center,
                TextColor = Color.FromRgb(98,98,98),
                Text = address.Address,
                FontSize = MyDevice.FontSizeSmall
            };

            var phoneLabel = new Label () {
                WidthRequest = MyDevice.GetScaledSize (360),
                HeightRequest = MyDevice.GetScaledSize(28),
                HorizontalTextAlignment = TextAlignment.Start,
                VerticalTextAlignment = TextAlignment.Center,
                TextColor = Color.FromRgb(98,98,98),
                Text = address.PhoneNumber,
                FontSize = MyDevice.FontSizeSmall
            };

            var tapGestureRecognizer = new TapGestureRecognizer ();
            tapGestureRecognizer.Tapped += (sender, e) => {

                mAddressModel.MakeActive(mAddressClass);
                mRootPage.SwitchActiveAddress(this);

            };
            mainLayout.GestureRecognizers.Add (tapGestureRecognizer);

            var editTapGestureRecognizer = new TapGestureRecognizer ();
            editTapGestureRecognizer.Tapped += (sender, e) => {
                mRootPage.mParent.LoadAddAddress(mAddressClass);
            };
            editButton.GestureRecognizers.Add (editTapGestureRecognizer);

            mainLayout.Children.Add (backgroundImage,
                Constraint.Constant (0),
                Constraint.Constant (0)
            );

            mainLayout.Children.Add (editButton,
                Constraint.RelativeToView (backgroundImage, (p, sibling) => {
                    return sibling.Bounds.Left + MyDevice.GetScaledSize (26);
                }),
                Constraint.RelativeToView (backgroundImage, (p, sibling) => {
                    return sibling.Bounds.Top + MyDevice.GetScaledSize (26);
                })
            );

            mainLayout.Children.Add (mActiveAddressImage,
                Constraint.RelativeToView (backgroundImage, (p, sibling) => {
                    return sibling.Bounds.Right - MyDevice.GetScaledSize (105);
                }),
                Constraint.RelativeToView (backgroundImage, (p, sibling) => {
                    return sibling.Bounds.Top + MyDevice.GetScaledSize (13);
                })
            );

            mainLayout.Children.Add (nameLabel,
                Constraint.RelativeToView (backgroundImage, (p, sibling) => {
                    return sibling.Bounds.Left + MyDevice.GetScaledSize (105);
                }),
                Constraint.RelativeToView (backgroundImage, (p, sibling) => {
                    return sibling.Bounds.Top + MyDevice.GetScaledSize (16);
                })
            );
            mainLayout.Children.Add (addressLabel,
                Constraint.RelativeToView (nameLabel, (p, sibling) => {
                    return sibling.Bounds.Left;
                }),
                Constraint.RelativeToView (nameLabel, (p, sibling) => {
                    return sibling.Bounds.Bottom + MyDevice.GetScaledSize (2);
                })
            );
            mainLayout.Children.Add (phoneLabel,
                Constraint.RelativeToView (addressLabel, (p, sibling) => {
                    return sibling.Bounds.Left;
                }),
                Constraint.RelativeToView (addressLabel, (p, sibling) => {
                    return sibling.Bounds.Bottom + MyDevice.GetScaledSize (2);
                })
            );

            mActiveAddressImage.IsVisible = !mAddressClass.IsActive;

            this.View = mainLayout;
        }
Example #32
0
        /**
         * Gets all records with the given domain and record type in the zone.
         */
        public IEnumerable <DNSRecord> Query(Domain domain, ResourceRecordType rtype, AddressClass addr_class)
        {
            var key = Tuple.Create(domain, rtype, addr_class);
            HashSet <DNSRecord> records;

            zone_records.TryGetValue(key, out records);

            if (records == null)
            {
                return(new HashSet <DNSRecord>());
            }
            else
            {
                return(records);
            }
        }
Example #33
0
 public HashSet <DNSRecord> Query(Domain domain, AddressClass cls, ResourceRecordType type)
 {
     return(new HashSet <DNSRecord>());
 }
Example #34
0
		private async void Submit()
		{
			if (mFocusedEntry != null)
				mFocusedEntry.Unfocus ();

			string address = AddressEntry.Text.ToString ();
			string activeRegion = RegionEntryLabel.Text.ToString ();
			string addressDescription = AddressDescriptionEntry.Text.ToString ();
			string addressLine3 = AddressLine3Entry.Text.ToString ();
			string name = NameEntry.Text.ToString () + " " + SurNameEntry.Text.ToString ();
			string phoneNumber = PhoneEntry.Text.ToString ();

			AddressClass addressClass = new AddressClass();
			addressClass.Name = name;
			addressClass.PhoneNumber = phoneNumber;
			addressClass.Address = address;
			addressClass.AddressDescription = addressDescription;
			addressClass.AddressLine3 = addressLine3;
			addressClass.ShopNumber = RegionHelper.DecideShopNumber (activeRegion);
			addressClass.IsActive = false;


			if (mAddressModel == null) {
				mAddressModel = new AddressClass ();
				mAddressModel.AddAddress (addressClass);
			} else {
				addressClass.Id = mAddressModel.Id;
				mAddressModel.UpdateAddress (addressClass);
			}

			mAddressModel.MakeActive (addressClass);

			await DisplayAlert ("User Information Submitted", "You have successfully submitted your information", "OK");

			mParent.LoadSettingsPage ();
		}
 public void AddItems(AddressClass item)
 {
     Address.Add(item);
 }
Example #36
0
		public void LoadAddAddress(AddressClass address = null)
		{
			mCurrentPageParent = "Settings";
			mAddAddressPage = (new AddAddressPage (address,this)); 
			SwitchContent (mAddAddressPage.Content);
		}
 public void UpdateAddress(AddressClass address)
 {
     _db.Entry(_db.CustomerAddress.Find(address.AddressID)).CurrentValues.SetValues(Map(address));
     Save();
 }
Example #38
0
        public NetworkBuilder(NetworkInfo Info)
        {
            //// Get the nessecary data to build the subnetting information

            //int NumberOfHostsNeeded = Info.NumberOfHosts;

            //// The nessecary address class for the number of subnets and the required hosts per subnet
            //AddressClass InetClass = DetermineNessecaryAddressClass(NumberOfHostsNeeded);

            //// Uses 2^x to determine how many bits need to be borrowed
            //int BitsToBorrow = DetermineBitsToBorrow(NumberOfHostsNeeded, InetClass);

            //int BitsForAddressSpace = DetermineBitsForAddressSpace(BitsToBorrow, InetClass);

            //int RequiredSubnets = DetermineNumberOfSubnets(BitsToBorrow, InetClass);

            int BitsToBorrow = DetermineBitsToBorrow(Info.RequiredSubnets);

            AddressClass InetClass = DetermineNessecaryAddressClass(Info.NumberOfHosts);

            int AddressSpaceBits = DetermineBitsForAddressSpace(BitsToBorrow, InetClass);

            int RequiredSubnets = IntPow(2, BitsToBorrow);

            // Gets the subnet mask using data resources basedo n the required bits to borrow
            SubnetMask NetMask       = GetSubnetAddress(InetClass, BitsToBorrow, AddressSpaceBits);
            IpAddress  SampleAddress = new IpAddress(Info.SampleAddress);


            // The program has different functionallity based on different address class
            // For Class C it will be able to build the entire subnet out
            // For the other classes it will display generic subnetting information but not build a subnet
            switch (InetClass)
            {
            case AddressClass.A:
                BuiltNetwork = new FullNetwork();
                // Gather network information for Class A
                //ClassAandBBuilder ClassABuilder = new ClassAandBBuilder();
                //ClassABuilder.NetMask = NetMask;
                //ClassABuilder.HostsPerSubnet = IntPow(2, (AddressSpaceBits - 2) );
                //ClassABuilder.NumberOfSubents = IntPow(2, BitsToBorrow);
                //BuiltNetwork.ClassAorBBuilder = ClassABuilder;
                BuiltNetwork = new FullNetwork();
                BuiltNetwork.BitsBorrowed    = BitsToBorrow;
                BuiltNetwork.Class           = InetClass;
                BuiltNetwork.NetMask         = NetMask;
                BuiltNetwork.NumberOfSubnets = IntPow(2, BitsToBorrow);
                BuiltNetwork.AddressSpace    = IntPow(2, AddressSpaceBits);
                BuiltNetwork.UsableHosts     = IntPow(2, AddressSpaceBits) - 2;
                break;

            case AddressClass.B:
                //BuiltNetwork = new FullNetwork();
                //ClassAandBBuilder ClassBBuilder = new ClassAandBBuilder();
                //ClassBBuilder.NetMask = NetMask;
                //ClassBBuilder.HostsPerSubnet = IntPow(2, AddressSpaceBits);
                //ClassBBuilder.NumberOfSubents = IntPow(2, BitsToBorrow);
                //BuiltNetwork.ClassAorBBuilder = ClassBBuilder;
                BuiltNetwork = new FullNetwork();
                BuiltNetwork.BitsBorrowed    = BitsToBorrow;
                BuiltNetwork.Class           = InetClass;
                BuiltNetwork.NetMask         = NetMask;
                BuiltNetwork.NumberOfSubnets = IntPow(2, BitsToBorrow);
                BuiltNetwork.AddressSpace    = IntPow(2, AddressSpaceBits);
                BuiltNetwork.UsableHosts     = IntPow(2, AddressSpaceBits) - 2;
                break;

            case AddressClass.C:
                // Gather network information for Class C
                int SubnetCount = 0;
                BuiltNetwork = new FullNetwork();
                // Begin the subnet building process
                ClassCSubnetBuilder ClassCBuilder = new ClassCSubnetBuilder(NetMask, SampleAddress);
                // Subtraction by one because it is a based of zero
                while (SubnetCount < RequiredSubnets)
                {
                    SubnetCount += 1;
                    Subnetwork Subnet = ClassCBuilder.NextSubnet();
                    BuiltNetwork.Subnets.Enqueue(Subnet);
                }

                BuiltNetwork.BitsBorrowed    = BitsToBorrow;
                BuiltNetwork.Class           = InetClass;
                BuiltNetwork.NetMask         = NetMask;
                BuiltNetwork.NumberOfSubnets = IntPow(2, BitsToBorrow);
                BuiltNetwork.AddressSpace    = (IntPow(2, AddressSpaceBits) * BuiltNetwork.NumberOfSubnets);
                BuiltNetwork.UsableHosts     = IntPow(2, AddressSpaceBits) - 2;

                break;

            default:
                break;
            }
        }