public static Occurrence SetupOccurrenceSearch(ComputerSystem kiosk)
        {
            const string userID = CheckInTestConstants.USER_ID;

            var occurrence = CheckInTestFactories.CreateOccurrence();
            var type       = CheckInTestFactories.CreateOccurrenceType();
            var group      = CheckInTestFactories.CreateOccurrenceTypeGroup();

            group.Save(userID);
            type.GroupId = group.GroupId;
            type.Save(userID);
            group.OccurrenceTypes.Add(type);
            group.Save(userID);

            occurrence.OccurrenceTypeID = type.OccurrenceTypeId;
            occurrence.Save(userID);
            type.Occurrences.Add(occurrence);
            type.Save(userID);

            var location = CheckInTestFactories.CreateLocation();

            location.OccurrenceTypes.Add(type);
            location.Save(userID);

            occurrence.LocationID = location.LocationId;
            occurrence.Save(userID);

            type.Locations.Add(location);
            type.Save(userID);

            kiosk.Locations.Add(location);
            kiosk.Save();
            kiosk.SaveLocations(new[] { location.LocationId });
            return(occurrence);
        }
        public static List <Occurrence> SetupOccurrenceSearchMultipleOccurrences(ComputerSystem kiosk)
        {
            List <Occurrence> occurrences = new List <Occurrence>();
            var occurrence = SetupOccurrenceSearch(kiosk);

            occurrences.Add(occurrence);

            var location = CheckInTestFactories.CreateLocation();

            location.OccurrenceTypes.Add(occurrence.OccurrenceType);
            location.Save(CheckInTestConstants.USER_ID);

            occurrence.OccurrenceType.Locations.Add(location);
            occurrence.OccurrenceType.Save(CheckInTestConstants.USER_ID);

            kiosk.Locations.Add(location);
            kiosk.Save();
            kiosk.SaveLocations(new[] { location.LocationId });

            var newOccurrence = CheckInTestFactories.CreateOccurrence();

            newOccurrence.OccurrenceTypeID = occurrence.OccurrenceTypeID;
            newOccurrence.StartTime        = occurrence.StartTime;
            newOccurrence.LocationID       = location.LocationId;
            newOccurrence.Save(CheckInTestConstants.USER_ID);

            occurrences.Add(newOccurrence);
            return(occurrences);
        }
        public static ComputerSystem SetupKiosk()
        {
            string         hostName = Dns.GetHostName();
            ComputerSystem system   = new ComputerSystem(hostName, true);
            IPHostEntry    ipEntry;

            if (system.SystemId == Constants.NULL_INT)
            {
                ipEntry = Dns.GetHostEntry(hostName);
                var ipAddress = ipEntry.AddressList.First();

                foreach (var ip in ipEntry.AddressList)
                {
                    system.LoadByKioskIp(ip.ToString());

                    if (system.SystemId != Constants.NULL_INT)
                    {
                        ipAddress = ip;
                        break;
                    }
                }

                system.Kiosk          = true;
                system.Active         = true;
                system.OrganizationId = CheckInTestConstants.ORG_ID;

                if (system.SystemId == Constants.NULL_INT)
                {
                    system.SystemName = string.Format("Test System - {0}", ipAddress);
                    system.Save();
                    system.RegisterIpAddresses(ipEntry.AddressList);
                }
                else
                {
                    system.Save();
                }
            }

            return(system);
        }
Ejemplo n.º 4
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (hfSystemID.Value != "-1")
            {
                kiosk = new ComputerSystem(Convert.ToInt32(hfSystemID.Value));
            }
            else
            {
                kiosk = new ComputerSystem();
            }

            kiosk.SystemName = txtName.Text;
            kiosk.DNSName    = txtDnsName.Text;
            kiosk.Notes      = txtDescription.Text;
            kiosk.Active     = true;
            kiosk.Kiosk      = true;

            ComputerSystemPrinter printer = null;

            if (ddlPrinters.SelectedValue != "-1")
            {
                printer = new ComputerSystemPrinter(Convert.ToInt32(ddlPrinters.SelectedValue));
            }

            kiosk.Printer = printer;
            kiosk.Save();

            // Save IP address
            ComputerSystemData data = new ComputerSystemData();

            data.SaveKioskIpAddress(kiosk.SystemId, txtIPAddress.Text);

            // save Locations
            data.DeleteSystemLocations(kiosk.SystemId);
            foreach (TreeViewNode node in tvLocations.CheckedNodes)
            {
                if (node.Depth == 1)
                {
                    data.SaveSystemLocation(kiosk.SystemId, Convert.ToInt32(node.ID));
                }
            }

            ReturnControl();
        }