Example #1
0
        /// <summary>
        /// Create new local device. Initialize device
        /// </summary>
        /// <param name="deviceType">The type of device on which the new record is created</param>
        /// <returns>New device definition</returns>
        public async Task <Device> CreateDevice(DeviceTypeEnum deviceType)
        {
            const string methodCode = "M01";

            Device device = new Device();

            device.DeviceId    = ShortGuid.NewGuid().Value;
            device.Name        = $"{deviceType.LocalizedName}";
            device.FolderId    = Guid.NewGuid().ToString("N");
            device.CreatedWhen = DateTimeOffset.Now;

            Log.Trace(methodCode, "Create Device {@DeviceType}", deviceType.LocalizedName);
            await dalRepo.SaveAsync(device);

            await Log.AuditAsync(AuditCodes.CreateDevice, DataTypeEnum.Device, device.DeviceId, SystemEntityGuidConst.UserSystem);

            /*
             * if(string.IsNullOrEmpty(app.ActualFoderDevices))
             * app.ActualFoderDevices = Guid.NewGuid().ToString("N");
             *
             * device.FolderId = app.ActualFoderDevices;
             * device.CreatedWhen = DateTimeOffset.Now;
             * device.UpdatedWhen = device.CreatedWhen;
             * return device;
             */
            return(null);
        }
Example #2
0
 public Device(DeviceTypeEnum deviceType, string deviceHandle, string deviceName, IntPtr appDeviceHandle)
 {
     this._deviceType      = deviceType;
     this._deviceHandle    = deviceHandle;
     this._deviceName      = deviceName;
     this._appDeviceHandle = appDeviceHandle;
 }
Example #3
0
        /// <summary>
        /// Creates a new machine and adds it to the internal list with a new internal machine index
        /// </summary>
        public IMachine CreateNew(string name,
                                  string machineHardwareID,
                                  MachineType machineType,
                                  DeviceTypeEnum deviceType,
                                  bool isJohnDoeMachine,
                                  Guid machineID)
        {
            var ExistingMachine = isJohnDoeMachine ? Locate(name, true) : Locate(machineID, false);

            if (ExistingMachine != null)
            {
                return(ExistingMachine);
            }

            // Create the new machine
            if (isJohnDoeMachine)
            {
                machineID = UniqueJohnDoeID();
            }

            // Determine the internal ID for the new machine.
            // Note: This assumes machines are never removed from a project

            var internalMachineID = (short)Count;

            var Result = new Machine(name, machineHardwareID, machineType, deviceType, machineID, internalMachineID, isJohnDoeMachine);

            // Add it to the list
            Add(Result);

            return(Result);
        }
Example #4
0
 public Device(int id, string name, string version, DeviceTypeEnum deviceType)
 {
     Id         = id;
     Name       = name;
     Version    = version;
     DeviceType = deviceType;
 }
Example #5
0
        public static DeviceTypeEnum GetConnectedDevice()
        {
            // In GUI, this will error message to be shown and then exits app
            DeviceTypeEnum connectedDevice = DeviceTypeEnum.None;

            // Check which cameras are connected,
            // Set the deviceType which is used to initialize the camera object

            if (ThorlabCamera.IsConnected())
            {
                connectedDevice = DeviceTypeEnum.Thorlabs;
            }

            else if (PS3Camera.CameraCount > 0)
            {
                connectedDevice = DeviceTypeEnum.PS3Eye;
            }

            //else if (KinectCamera.IsConnected())
            //    deviceType = DeviceTypeEnum.Kinect;

            else if (DirectShowDevices.Instance.Cameras.Count() > 0)
            {
                connectedDevice = DeviceTypeEnum.DirectShow;
            }

            return(connectedDevice);
        }
Example #6
0
        private Camera()
        {
            // Check connected device
            deviceType = GetConnectedDevice();

            // Create camera subclass object, inherits from CameraBase
            switch (deviceType)
            {
            case DeviceTypeEnum.Thorlabs:
                camera = new ThorlabCamera();     // needs hwndSource to work, set by this.HwndSource property
                break;

            case DeviceTypeEnum.PS3Eye:
                camera = new PS3Camera();
                break;

            case DeviceTypeEnum.Kinect:
                camera = new KinectCamera();
                break;

            case DeviceTypeEnum.DirectShow:
                camera = new DirectShowCamera();
                break;
            }
        }
Example #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (ServerPartition != null)
            {
                // This make sure we have the list to work with.
                // the list may be out-dated if the add/update event is fired later
                // In those cases, the list must be refreshed again.
                LoadDevices();

                IList <DeviceTypeEnum> deviceTypes = DeviceTypeEnum.GetAll();

                if (DeviceTypeFilter.Items.Count == 0)
                {
                    foreach (DeviceTypeEnum t in deviceTypes)
                    {
                        DeviceTypeFilter.Items.Add(new ListItem(ServerEnumDescription.GetLocalizedDescription(t), t.Lookup));
                    }
                }
                else
                {
                    var typeItems = new ListItem[DeviceTypeFilter.Items.Count];
                    DeviceTypeFilter.Items.CopyTo(typeItems, 0);
                    DeviceTypeFilter.Items.Clear();
                    int count = 0;
                    foreach (DeviceTypeEnum t in deviceTypes)
                    {
                        DeviceTypeFilter.Items.Add(new ListItem(ServerEnumDescription.GetLocalizedDescription(t), t.Lookup));
                        DeviceTypeFilter.Items[count].Selected = typeItems[count].Selected;
                        count++;
                    }
                }
            }
        }
        // This method performs a thread-safe decrementation the objects count.

        public static int UncountObject(DeviceTypeEnum devType)
        {
            int retval;

            // Decrement the count of objects for the specified device type.

            if (devType == DeviceTypeEnum.Telescope)
            {
                Interlocked.Decrement(ref _scopesInUse);
            }
            else if (devType == DeviceTypeEnum.Dome)
            {
                Interlocked.Decrement(ref _domesInUse);
            }
            else if (devType == DeviceTypeEnum.Focuser)
            {
                Interlocked.Decrement(ref _focusersInUse);
            }

            // Decrement the global count of objects.

            retval = Interlocked.Decrement(ref _objsInUse);

            Messenger.Default.Send(new ObjectCountMessage(_scopesInUse, _domesInUse, _focusersInUse));

            return(retval);
        }
        public DeviceManagerBase(DeviceTypeEnum deviceType)
        {
            DeviceType = deviceType;

            ThrowOnInvalidPropertyName = false;
            _messageBoxService         = null;

            Exceptions = new PropertyExceptions();
        }
Example #10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            ServerPartitionDataAdapter    adaptor  = new ServerPartitionDataAdapter();
            ServerPartitionSelectCriteria criteria = new ServerPartitionSelectCriteria();

            criteria.AeTitle.EqualTo(Request.QueryString[ImageServerConstants.QueryStrings.ServerAE]);
            _partition = adaptor.GetFirst(criteria);

            for (int i = 1;; i++)
            {
                string qs       = string.Format(ImageServerConstants.QueryStrings.StudyUID + "{0}", i);
                string studyuid = Request.QueryString[qs];

                if (!string.IsNullOrEmpty(studyuid))
                {
                    _studies.Add(LoadStudy(studyuid));
                }
                else
                {
                    break;
                }
            }

            StudyGridPanel.StudyList = _studies;

            LoadDevices();

            if (DHCPFilter.Items.Count == 0)
            {
                DHCPFilter.Items.Add(new ListItem(SR.All));
                DHCPFilter.Items.Add(new ListItem(SR.DHCP));
                DHCPFilter.Items.Add(new ListItem(SR.NoDHCP));
            }

            IList <DeviceTypeEnum> deviceTypes = DeviceTypeEnum.GetAll();

            if (DeviceTypeFilter.Items.Count == 0)
            {
                foreach (DeviceTypeEnum t in deviceTypes)
                {
                    DeviceTypeFilter.Items.Add(new ListItem(ServerEnumDescription.GetLocalizedDescription(t), t.Lookup));
                }
            }
            else
            {
                ListItem[] typeItems = new ListItem[DeviceTypeFilter.Items.Count];
                DeviceTypeFilter.Items.CopyTo(typeItems, 0);
                DeviceTypeFilter.Items.Clear();
                int count = 0;
                foreach (DeviceTypeEnum t in deviceTypes)
                {
                    DeviceTypeFilter.Items.Add(new ListItem(ServerEnumDescription.GetLocalizedDescription(t), t.Lookup));
                    DeviceTypeFilter.Items[count].Selected = typeItems[count].Selected;
                    count++;
                }
            }
        }
        /// <summary>
        /// Removes the pairing with a given Smart Device
        /// </summary>
        /// <param name="nukiId"></param>
        /// <returns>RequestResult</returns>
        public RequestResult UnPair(int nukiId, DeviceTypeEnum deviceType)
        {
            var request = new RestRequest("unpair");

            request.AddQueryParameter("nukiId", nukiId.ToString());
            request.AddQueryParameter("deviceType", deviceType.ToString("d"));

            return(Execute <RequestResult>(request));
        }
Example #12
0
        /// <summary>
        /// Load the devices for the partition based on the filters specified in the filter panel.
        /// </summary>
        /// <remarks>
        /// This method only reloads and binds the list bind to the internal grid. <seealso cref="Refresh"/> should be called
        /// to explicit update the list in the grid.
        /// <para>
        /// This is intentionally so that the list can be reloaded so that it is available to other controls during postback.  In
        /// some cases we may not want to refresh the list if there's no change. Calling <seealso cref="Refresh"/> will
        /// give performance hit as the data will be transfered back to the browser.
        ///
        /// </para>
        /// </remarks>
        public void LoadDevices()
        {
            if (ServerPartition == null)
            {
                return;
            }

            var criteria = new DeviceSelectCriteria();

            // only query for device in this partition
            criteria.ServerPartitionKey.EqualTo(ServerPartition.GetKey());

            if (!String.IsNullOrEmpty(AETitleFilter.TrimText))
            {
                QueryHelper.SetGuiStringCondition(criteria.AeTitle,
                                                  SearchHelper.LeadingAndTrailingWildCard(AETitleFilter.TrimText));
            }

            if (!String.IsNullOrEmpty(DescriptionFilter.TrimText))
            {
                QueryHelper.SetGuiStringCondition(criteria.Description,
                                                  SearchHelper.LeadingAndTrailingWildCard(DescriptionFilter.TrimText));
            }

            if (!String.IsNullOrEmpty(IPAddressFilter.TrimText))
            {
                QueryHelper.SetGuiStringCondition(criteria.IpAddress,
                                                  SearchHelper.TrailingWildCard(IPAddressFilter.TrimText));
            }

            if (StatusFilter.SelectedIndex != 0)
            {
                criteria.Enabled.EqualTo(StatusFilter.SelectedIndex == 1);
            }

            if (DHCPFilter.SelectedIndex != 0)
            {
                criteria.Dhcp.EqualTo(DHCPFilter.SelectedIndex == 1);
            }

            if (DeviceTypeFilter.SelectedIndex > -1)
            {
                var types = new List <DeviceTypeEnum>();
                foreach (ListItem item in DeviceTypeFilter.Items)
                {
                    if (item.Selected)
                    {
                        types.Add(DeviceTypeEnum.GetEnum(item.Value));
                    }
                }
                criteria.DeviceTypeEnum.In(types);
            }

            DeviceGridViewControl1.Devices = _theController.GetDevices(criteria);
            DeviceGridViewControl1.RefreshCurrentPage();
        }
Example #13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PaymentDevice" /> class.
 /// </summary>
 /// <param name="deviceType">The data format. (required).</param>
 /// <param name="data">Data from device containing, at a minimum, a transaction-unique key serial number (KSN) and track 2 card data. (required).</param>
 /// <param name="securityCode">Card verification value/number..</param>
 /// <param name="cardholderName">Name of cardholder..</param>
 /// <param name="cardFunction">cardFunction.</param>
 /// <param name="brand">The card brand..</param>
 public PaymentDevice(DeviceTypeEnum deviceType = default(DeviceTypeEnum), string data = default(string), string securityCode = default(string), string cardholderName = default(string), CardFunction?cardFunction = null, string brand = default(string))
 {
     this.DeviceType = deviceType;
     // to ensure "data" is required (not null)
     this.Data           = data ?? throw new ArgumentNullException("data is a required property for PaymentDevice and cannot be null");
     this.SecurityCode   = securityCode;
     this.CardholderName = cardholderName;
     this.CardFunction   = cardFunction;
     this.Brand          = brand;
 }
        /// <summary>
        /// Performs a lock operation on the given Smart Device
        /// </summary>
        /// <param name="nukiId"></param>
        /// <param name="action"></param>
        /// <param name="deviceType"></param>
        /// <param name="noWait"></param>
        /// <returns>LockActionResult</returns>
        public LockActionResult LockAction(int nukiId, DeviceTypeEnum deviceType, LockActionEnum action, bool noWait = false)
        {
            var request = new RestRequest("lockAction");

            request.AddQueryParameter("nukiId", nukiId.ToString());
            request.AddQueryParameter("deviceType", ((int)deviceType).ToString());
            request.AddQueryParameter("action", ((int)action).ToString());
            request.AddQueryParameter("nowait", noWait ? "1" : "0");

            return(Execute <LockActionResult>(request));
        }
    /// <summary>
    /// Gets an IMessageTransformer implementation for the Device Type given.
    /// </summary>
    /// <param name="deviceType">The DeviceType that the factory must create an IMessageTransformer for.</param>
    public IMessageTransformer <T> CreateTransformer <T>(DeviceTypeEnum deviceType) where T : class
    {
        // If we have a factory method, then we use it.
        if (factoryMethod == null)
        {
            throw new NullReferenceException("The MessageTransformerFactory did not have its factory method set.");
        }
        // Cast the non-generic return value to the generic version for the caller.
        Type transformerType = MessageTransformFactory.deviceTransformerMapCache[deviceType];

        return(factoryMethod(transformerType) as IMessageTransformer <T>);
    }
Example #16
0
        public async Task <int> UpdateCheckTime(DeviceTypeEnum deviceType, int deviceNum)
        {
            var device =
                await BaseRepository.Table.FirstOrDefaultAsync(f => f.DeviceType == deviceType && f.DeviceNum == deviceNum);

            if (device != null)
            {
                device.LastCheckTime = DateTime.Now;
                return(await _unitOfWork.SaveChangesAsync());
            }

            return(0);
        }
        public void UpdateUI()
        {
            // update the dropdown list
            DeviceTypeDropDownList.Items.Clear();
            IList <DeviceTypeEnum> deviceTypes = DeviceTypeEnum.GetAll();

            foreach (DeviceTypeEnum t in deviceTypes)
            {
                DeviceTypeDropDownList.Items.Add(
                    new ListItem(ServerEnumDescription.GetLocalizedDescription(t), t.Lookup)
                    );
            }

            UpdateLabels();

            // Update the rest of the fields
            if (Device == null)
            {
                AETitleTextBox.Text                = SR.DeviceAE;
                IPAddressTextBox.Text              = string.Empty;
                ActiveCheckBox.Checked             = true;
                DHCPCheckBox.Checked               = false;
                DescriptionTextBox.Text            = string.Empty;
                PortTextBox.Text                   = SR.DeviceDefaultPort;
                DefaultSCSTextBox.Text             = string.Empty;
                AllowStorageCheckBox.Checked       = true;
                AllowQueryCheckBox.Checked         = true;
                AllowRetrieveCheckBox.Checked      = true;
                AllowAutoRouteCheckBox.Checked     = true;
                ThrottleSettingsTab.MaxConnections = UICommonSettings.Admin.Device.MaxConnections;
            }
            else if (Page.IsValid)
            {
                AETitleTextBox.Text                = Device.AeTitle;
                IPAddressTextBox.Text              = Device.IpAddress;
                ActiveCheckBox.Checked             = Device.Enabled;
                DHCPCheckBox.Checked               = Device.Dhcp;
                DescriptionTextBox.Text            = Device.Description;
                DefaultSCSTextBox.Text             = Device.DefaultSCS;
                PortTextBox.Text                   = Device.Port.ToString();
                AcceptKOPR.Checked                 = Device.AcceptKOPR;
                AllowStorageCheckBox.Checked       = Device.AllowStorage;
                AllowQueryCheckBox.Checked         = Device.AllowQuery;
                AllowRetrieveCheckBox.Checked      = Device.AllowRetrieve;
                AllowAutoRouteCheckBox.Checked     = Device.AllowAutoRoute;
                ThrottleSettingsTab.MaxConnections = Device.ThrottleMaxConnections;
            }
        }
Example #18
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Device" /> class.
 /// </summary>
 /// <param name="deviceType">Defines the type of this object. (required).</param>
 /// <param name="deviceId">The unique ID of the device. Must be unique for the entire system (not just within a specific merchant or industry). (required).</param>
 /// <param name="networks">Information about the networks associated with the device..</param>
 /// <param name="latitude">The GPS decimal latitude, ranging from (-90.0 to 90.0) where positive numbers indicate locations North of the equator..</param>
 /// <param name="longitude">The GPS decimal longitude, ranging from (-180.0 to 180.0) where positive numbers indicate locations East of the IERS Reference Meridian..</param>
 /// <param name="imei">The device&#39;s International Mobile Equipment Identity (IMEI) as described in IETF RFC7254..</param>
 /// <param name="model">The device&#39;s model name..</param>
 /// <param name="manufacturer">The device&#39;s manufacturer..</param>
 /// <param name="timezoneOffset">The timezone offset from UTC to the devices timezone configuration, specified in the format +hh:mm..</param>
 /// <param name="rooted">A flag indicating that the device has been altered to allow privileged access to users. This flag should only be set to false if a test was performed and the result was negative. Leave unset otherwise..</param>
 /// <param name="malwareDetected">A flag indicating that malware was detected on the mobile phone. This flag should only be set to false if a test was performed and the result was negative. Leave unset otherwise..</param>
 /// <param name="userDefined">A JSON object that can carry any additional information about the device that might be helpful for fraud detection..</param>
 public Device(DeviceTypeEnum deviceType = default(DeviceTypeEnum), string deviceId = default(string), List <Items> networks = default(List <Items>), decimal latitude = default(decimal), decimal longitude = default(decimal), string imei = default(string), string model = default(string), string manufacturer = default(string), string timezoneOffset = default(string), bool rooted = default(bool), bool malwareDetected = default(bool), Object userDefined = default(Object))
 {
     this.DeviceType = deviceType;
     // to ensure "deviceId" is required (not null)
     this.DeviceId        = deviceId ?? throw new ArgumentNullException("deviceId is a required property for Device and cannot be null");
     this.Networks        = networks;
     this.Latitude        = latitude;
     this.Longitude       = longitude;
     this.Imei            = imei;
     this.Model           = model;
     this.Manufacturer    = manufacturer;
     this.TimezoneOffset  = timezoneOffset;
     this.Rooted          = rooted;
     this.MalwareDetected = malwareDetected;
     this.UserDefined     = userDefined;
 }
        public void Insert(Guid Guid, short EnumX, string Lookup, string Description, string LongDescription)
        {
            var item = new DeviceTypeEnum();

            item.Guid = Guid;

            item.EnumX = EnumX;

            item.Lookup = Lookup;

            item.Description = Description;

            item.LongDescription = LongDescription;


            item.Save(UserName);
        }
        private void SelectActiveTab()
        {
            DeviceTypeEnum device = Globals.ActiveDevice;

            string devName     = device.ToString();
            bool   canBeActive = true;

            switch (devName)
            {
            case "Telescope":
                if (TelescopeManager.Instance.IsConnected)
                {
                    canBeActive = false;
                }

                break;

            case "Dome":
                if (DomeManager.Instance.IsConnected)
                {
                    canBeActive = false;
                }

                break;

            case "Focuser":
                if (FocuserManager.Instance.IsConnected)
                {
                    canBeActive = false;
                }

                break;
            }

            // This only works if all of the tab items have a defined Tag property.

            if (canBeActive)
            {
                TabItem item = _deviceTab.Items.OfType <TabItem>().SingleOrDefault(i => i.Tag.ToString() == devName);

                _deviceTab.SelectedItem = item;
            }
        }
Example #21
0
        public async Task <Device> UpdateStateAsync(DeviceTypeEnum deviceType, int deviceNum, int deviceState)
        {
            var entity =
                await BaseRepository.Table.FirstOrDefaultAsync(r => r.DeviceType == deviceType && r.DeviceNum == deviceNum);

            if (entity != null)
            {
                //如果是通讯异常报警,该项由上级设备上报状态,顾累加到现有状态上
                if (deviceState == 2 && (entity.DeviceState & 2) != 2)
                {
                    entity.DeviceState += 2;
                }
                else
                {
                    entity.DeviceState = deviceState;
                }
                entity.LastCheckTime = DateTime.Now;
                await _unitOfWork.SaveChangesAsync();
            }
            return(entity);
        }
        private DeviceTypeEnum GetDeviceType()
        {
            DeviceTypeEnum devType = DeviceTypeEnum.Unknown;

            // We increment the global count of objects.

            if (this is ITelescopeV3)
            {
                devType = DeviceTypeEnum.Telescope;
            }
            else if (this is IDomeV2)
            {
                devType = DeviceTypeEnum.Dome;
            }
            else if (this is IFocuserV3)
            {
                devType = DeviceTypeEnum.Focuser;
            }

            return(devType);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="InstallationObject" /> class.
 /// </summary>
 /// <param name="id">id (required).</param>
 /// <param name="deviceToken">deviceToken (required).</param>
 /// <param name="deviceType">deviceType (required).</param>
 /// <param name="meta">meta (required).</param>
 /// <param name="channels">channels.</param>
 public InstallationObject(string id = default(string), string deviceToken = default(string), DeviceTypeEnum deviceType = default(DeviceTypeEnum), MetaInstallationObject meta = default(MetaInstallationObject), List <string> channels = default(List <string>)) : base()
 {
     // to ensure "id" is required (not null)
     if (id == null)
     {
         throw new InvalidDataException("id is a required property for InstallationObject and cannot be null");
     }
     else
     {
         this.Id = id;
     }
     // to ensure "deviceToken" is required (not null)
     if (deviceToken == null)
     {
         throw new InvalidDataException("deviceToken is a required property for InstallationObject and cannot be null");
     }
     else
     {
         this.DeviceToken = deviceToken;
     }
     // to ensure "deviceType" is required (not null)
     if (deviceType == null)
     {
         throw new InvalidDataException("deviceType is a required property for InstallationObject and cannot be null");
     }
     else
     {
         this.DeviceType = deviceType;
     }
     // to ensure "meta" is required (not null)
     if (meta == null)
     {
         throw new InvalidDataException("meta is a required property for InstallationObject and cannot be null");
     }
     else
     {
         this.Meta = meta;
     }
     this.Channels = channels;
 }
Example #24
0
        private Camera()
        {
            // Check connected device
            deviceType = GetConnectedDevice();

            // Create camera subclass object, inherits from CameraBase
            switch (deviceType)
            {
                case DeviceTypeEnum.Thorlabs:
                    camera = new ThorlabCamera(); // needs hwndSource to work, set by this.HwndSource property
                    break;
                case DeviceTypeEnum.PS3Eye:
                    camera = new PS3Camera();
                    break;
                case DeviceTypeEnum.Kinect:
                    camera = new KinectCamera();
                    break;
                case DeviceTypeEnum.DirectShow:
                    camera = new DirectShowCamera();
                    break;

            }
        }
Example #25
0
        private void TabControl_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
        {
            if (sender is TabControl ctrl)
            {
                if (ctrl.SelectedItem is TabItem item)
                {
                    string label = item.Header.ToString().ToLower();

                    DeviceTypeEnum device = DeviceTypeEnum.Telescope;

                    if (label == "dome")
                    {
                        device = DeviceTypeEnum.Dome;
                    }
                    else if (label == "focuser")
                    {
                        device = DeviceTypeEnum.Focuser;
                    }

                    Globals.ActiveDevice = device;
                }
            }
        }
Example #26
0
        public static DeviceTypeEnum GetConnectedDevice()
        {
            // In GUI, this will error message to be shown and then exits app
            DeviceTypeEnum connectedDevice = DeviceTypeEnum.None;

            // Check which cameras are connected,
            // Set the deviceType which is used to initialize the camera object

            //if (ThorlabCamera.IsConnected())
            //{
            //  connectedDevice = DeviceTypeEnum.Thorlabs;
            //}
            //else if (!DisablePs3Camera)
            //{
            //  try
            //  {
            //    if (PS3Camera.CameraCount > 0)
            //    {
            //      connectedDevice = DeviceTypeEnum.PS3Eye;
            //    }
            //  }
            //  catch (Exception)
            //  {
            //    DisablePs3Camera = true;
            //  }
            //}
            //else if (KinectCamera.IsConnected())
            //    deviceType = DeviceTypeEnum.Kinect;

            if (connectedDevice == DeviceTypeEnum.None && DirectShowDevices.Instance.Cameras.Any())
            {
                // Fallback to DirectShow drivers
                connectedDevice = DeviceTypeEnum.DirectShow;
            }

            return(connectedDevice);
        }
        private void SaveData()
        {
            if (Device == null)
            {
                Device = new Device();
            }

            Device.Enabled     = ActiveCheckBox.Checked;
            Device.AeTitle     = AETitleTextBox.Text;
            Device.Description = DescriptionTextBox.Text;
            Device.Dhcp        = DHCPCheckBox.Checked;
            Device.IpAddress   = IPAddressTextBox.Text;
            Device.DefaultSCS  = DefaultSCSTextBox.Text;
            int port;

            if (Int32.TryParse(PortTextBox.Text, out port))
            {
                Device.Port = port;
            }
            Device.ServerPartitionKey = DevicePage.CurrentPartition;
            Device.AllowStorage       = AllowStorageCheckBox.Checked;
            Device.AllowQuery         = AllowQueryCheckBox.Checked;
            Device.AllowRetrieve      = AllowRetrieveCheckBox.Checked;
            Device.AllowAutoRoute     = AllowAutoRouteCheckBox.Checked;

            if (AllowStorageCheckBox.Checked)
            {
                Device.AcceptKOPR = AcceptKOPR.Checked;
            }
            else
            {
                Device.AcceptKOPR = false;
            }

            Device.ThrottleMaxConnections = ThrottleSettingsTab.MaxConnections;
            Device.DeviceTypeEnum         = DeviceTypeEnum.GetEnum(DeviceTypeDropDownList.SelectedItem.Value);
        }
        public void Update(Guid Guid, short EnumX, string Lookup, string Description, string LongDescription)
        {
            var item = new DeviceTypeEnum();
            item.MarkOld();
            item.IsLoaded = true;

            item.Guid = Guid;

            item.EnumX = EnumX;

            item.Lookup = Lookup;

            item.Description = Description;

            item.LongDescription = LongDescription;

            item.Save(UserName);
        }
 public TransformableAttribute(DeviceTypeEnum deviceType)
 {
     this.DeviceType = deviceType;
 }
Example #30
0
        public object replaceDevice(Dictionary <string, object> dicParas)
        {
            try
            {
                string errMsg         = string.Empty;
                string mobileToken    = dicParas.ContainsKey("mobileToken") ? dicParas["mobileToken"].ToString() : string.Empty;
                string oldDeviceToken = dicParas.ContainsKey("oldDeviceToken") ? dicParas["oldDeviceToken"].ToString() : string.Empty;
                string newDeviceToken = dicParas.ContainsKey("newDeviceToken") ? dicParas["newDeviceToken"].ToString() : string.Empty;

                Base_MerchInfo merch = MerchBusiness.GetMerchModel(mobileToken);
                if (merch.IsNull())
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "用户令牌无效"));
                }

                Base_DeviceInfo oldDevice = DeviceBusiness.GetDeviceModel(oldDeviceToken);
                if (oldDevice.IsNull())
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "您要替换的设备令牌无效"));
                }

                //设备所属商户不是当前商户
                if (oldDevice.MerchID != merch.ID)
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "该设备不属于当前商户,没有权限操作该设备"));
                }

                //新设备实体
                Base_DeviceInfo newDevice = DeviceBusiness.GetDeviceModel(newDeviceToken);
                if (newDevice.IsNull())
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "当前扫面的设备令牌无效"));
                }

                //判断设备类别是否相同
                if (oldDevice.DeviceType != newDevice.DeviceType)
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "设备类型不同,不能替换"));
                }

                DeviceTypeEnum currDeviceType = (DeviceTypeEnum)oldDevice.DeviceType;
                int            category       = 0;

                switch (currDeviceType)
                {
                case DeviceTypeEnum.Router:
                    category = 1;
                    break;

                case DeviceTypeEnum.SlotMachines:
                case DeviceTypeEnum.DepositMachine:
                    category = 2;
                    break;

                case DeviceTypeEnum.Clerk:
                case DeviceTypeEnum.Terminal:
                    category = 3;
                    break;
                }

                if (category != 0)
                {
                    string         sql        = "exec ReplaceDevice @oldDeviceId,@newDeviceId,@merchId,@category";
                    SqlParameter[] parameters = new SqlParameter[4];
                    parameters[0] = new SqlParameter("@oldDeviceId", oldDevice.ID);
                    parameters[1] = new SqlParameter("@newDeviceId", newDevice.ID);
                    parameters[2] = new SqlParameter("@merchId", merch.ID);
                    parameters[3] = new SqlParameter("@category", category);
                    int ret = XCCloudRS232BLL.ExecuteSql(sql, parameters);
                    if (ret == 0)
                    {
                        return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "设备替换失败"));
                    }
                }

                //修改设备缓存状态
                DeviceStatusBusiness.SetDeviceState(oldDevice.Token, DeviceStatusEnum.未激活.ToDescription());
                DeviceStatusBusiness.SetDeviceState(newDevice.Token, DeviceStatusEnum.离线.ToDescription());

                return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.T, ""));
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Example #31
0
        public object updateDeviceState(Dictionary <string, object> dicParas)
        {
            try
            {
                string errMsg      = string.Empty;
                string mobileToken = dicParas.ContainsKey("mobileToken") ? dicParas["mobileToken"].ToString() : string.Empty;
                string deviceToken = dicParas.ContainsKey("deviceToken") ? dicParas["deviceToken"].ToString() : string.Empty;
                string status      = dicParas.ContainsKey("status") ? dicParas["status"].ToString() : string.Empty;

                Base_MerchInfo merch = MerchBusiness.GetMerchModel(mobileToken);
                if (merch.IsNull())
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "用户令牌无效"));
                }

                Base_DeviceInfo device = DeviceBusiness.GetDeviceModel(deviceToken);
                if (device.IsNull())
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "设备令牌无效"));
                }

                //设备所属商户不是当前商户
                if (device.MerchID != merch.ID)
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "该设备属于其他商户,您没有权限查看该设备"));
                }

                if (string.IsNullOrWhiteSpace(status))
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "参数错误"));
                }

                int    routerId       = 0;
                string strHeadAddress = string.Empty;

                //当前设备类型
                DeviceTypeEnum currDeviceType = (DeviceTypeEnum)device.DeviceType;
                switch (currDeviceType)
                {
                case DeviceTypeEnum.SlotMachines:
                case DeviceTypeEnum.DepositMachine:
                {
                    //获取外设绑定关系实体
                    Data_MerchDevice md = MerchDeviceBusiness.GetMerchDeviceModel(device.ID);
                    if (md.IsNull())
                    {
                        return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "设备未绑定"));
                    }

                    //获取控制器ID
                    routerId       = (int)md.ParentID;
                    strHeadAddress = md.HeadAddress;
                }
                break;

                case DeviceTypeEnum.Clerk:
                case DeviceTypeEnum.Terminal:
                {
                    //获取终端绑定关系实体
                    Data_MerchSegment ms = MerchSegmentBusiness.GetMerchSegmentModel(device.ID);
                    if (ms.IsNull())
                    {
                        return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "设备未绑定"));
                    }

                    //获取控制器ID
                    routerId       = (int)ms.ParentID;
                    strHeadAddress = ms.HeadAddress;
                }
                break;
                }

                Base_DeviceInfo router = null;

                if (routerId != 0)
                {
                    //获取当前设备所属的控制器实体
                    router = DeviceBusiness.GetDeviceModelById(routerId);
                }

                if (router == null)
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "获取控制器信息失败"));
                }

                if (string.IsNullOrWhiteSpace(strHeadAddress))
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "获取设备地址失败"));
                }

                //雷达处理指令
                switch (status.Trim())
                {
                //启用
                case "1":
                    device.DeviceType = (int)DeviceStatusEnum.启用;
                    DeviceBusiness.UpdateDevice(device);
                    DeviceStatusBusiness.SetDeviceState(device.Token, DeviceStatusEnum.离线.ToDescription());
                    break;

                //停用
                case "2":
                    device.DeviceType = (int)DeviceStatusEnum.停用;
                    DeviceBusiness.UpdateDevice(device);
                    DeviceStatusBusiness.SetDeviceState(device.Token, DeviceStatusEnum.停用.ToDescription());
                    break;

                //锁定
                case "3":
                    UDPServer.server.机头锁定解锁指令(router.Token, strHeadAddress, true);
                    DeviceStatusBusiness.SetDeviceState(device.Token, DeviceStatusEnum.锁定.ToDescription());
                    break;

                //解除锁定
                case "4":
                    UDPServer.server.机头锁定解锁指令(router.Token, strHeadAddress, false);
                    DeviceStatusBusiness.SetDeviceState(device.Token, DeviceStatusEnum.在线.ToDescription());
                    break;

                //解除报警
                case "5": break;
                    ////投币
                    //case "6":
                    //    UDPServer.server.远程投币上分(router.Token, strHeadAddress, "10000010", 5);
                    //    break;
                    ////退币
                    //case "7":
                    //    UDPServer.server.远程退币(router.Token, strHeadAddress);
                    //    break;
                }

                //if (state == DeviceStatusEnum.停用 || state == DeviceStatusEnum.启用)
                //{
                //    device.Status = (int)state;
                //    DeviceBusiness.UpdateDevice(device);
                //}

                return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.T, ""));
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Example #32
0
        public object getMerchDeviceInfo(Dictionary <string, object> dicParas)
        {
            try
            {
                string errMsg      = string.Empty;
                string mobileToken = dicParas.ContainsKey("mobileToken") ? dicParas["mobileToken"].ToString() : string.Empty;
                string deviceToken = dicParas.ContainsKey("deviceToken") ? dicParas["deviceToken"].ToString() : string.Empty;

                Base_MerchInfo merch = MerchBusiness.GetMerchModel(mobileToken);
                if (merch.IsNull())
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "用户令牌无效"));
                }

                Base_DeviceInfo device = DeviceBusiness.GetDeviceModel(deviceToken);
                if (device.IsNull())
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "设备令牌无效"));
                }

                //设备所属商户不是当前商户
                if (device.MerchID != merch.ID)
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "该设备属于其他商户,您没有权限查看该设备"));
                }

                DeviceTypeEnum currDeviceType = (DeviceTypeEnum)device.DeviceType;

                DeviceInfoModel model = new DeviceInfoModel();
                model.Router      = new Router();
                model.Group       = new Group();
                model.deviceName  = device.DeviceName ?? device.SN;
                model.deviceToken = device.Token;
                model.deviceType  = currDeviceType.ToDescription();
                model.deviceSN    = device.SN;
                model.status      = DeviceStatusBusiness.GetDeviceState(device.Token);

                switch (currDeviceType)
                {
                case DeviceTypeEnum.SlotMachines:
                case DeviceTypeEnum.DepositMachine:
                {
                    //获取外设绑定关系实体
                    Data_MerchDevice md = MerchDeviceBusiness.GetMerchDeviceModel(device.ID);
                    model.headAddress = md.HeadAddress;

                    //获取控制器实体
                    Base_DeviceInfo router = DeviceBusiness.GetDeviceModelById((int)md.ParentID);
                    model.Router.routerName  = router.DeviceName ?? router.SN;
                    model.Router.routerToken = router.Token;
                    model.Router.sn          = router.SN;
                }
                break;

                case DeviceTypeEnum.Clerk:
                case DeviceTypeEnum.Terminal:
                {
                    //获取终端绑定关系实体
                    Data_MerchSegment ms = MerchSegmentBusiness.GetMerchSegmentModel(device.ID);
                    model.headAddress = ms.HeadAddress;

                    //获取分组实体
                    Data_GameInfo group = GameBusiness.GetGameInfoModel(Convert.ToInt32(ms.GroupID));
                    model.Group.groupId   = group.GroupID;
                    model.Group.groupName = group.GroupName;
                    model.Group.groupType = ((GroupTypeEnum)(int)group.GroupType).ToDescription();
                }
                break;
                }
                return(ResponseModelFactory <DeviceInfoModel> .CreateModel(isSignKeyReturn, model));
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Example #33
0
        public object removeDevice(Dictionary <string, object> dicParas)
        {
            try
            {
                string errMsg      = string.Empty;
                string mobileToken = dicParas.ContainsKey("mobileToken") ? dicParas["mobileToken"].ToString() : string.Empty;
                string deviceToken = dicParas.ContainsKey("deviceToken") ? dicParas["deviceToken"].ToString() : string.Empty;

                Base_MerchInfo merch = MerchBusiness.GetMerchModel(mobileToken);
                if (merch.IsNull())
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "用户令牌无效"));
                }

                Base_DeviceInfo device = DeviceBusiness.GetDeviceModel(deviceToken);
                if (device.IsNull())
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "设备令牌无效"));
                }

                //设备所属商户不是当前商户
                if (device.MerchID != merch.ID)
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "该设备已被其他商户绑定,没有权限操作该设备"));
                }

                //开始解除绑定
                device.MerchID = 0;
                device.Status  = (int)DeviceStatusEnum.未激活;

                DeviceTypeEnum currDeviceType = (DeviceTypeEnum)device.DeviceType;
                bool           ret            = false;

                switch (currDeviceType)
                {
                case DeviceTypeEnum.Router:
                {
                    string sql = string.Format("exec RemoveMerchRouter {0}", device.ID);
                    XCCloudRS232BLL.ExecuteSql(sql);

                    //ret = DeviceBusiness.UpdateDevice(device);
                }
                break;

                case DeviceTypeEnum.SlotMachines:
                case DeviceTypeEnum.DepositMachine:
                {
                    //获取外设绑定关系实体
                    Data_MerchDevice md = MerchDeviceBusiness.GetMerchDeviceModel(device.ID);

                    using (var transactionScope = new System.Transactions.TransactionScope(TransactionScopeOption.RequiresNew))
                    {
                        DeviceBusiness.UpdateDevice(device);
                        ret = MerchDeviceBusiness.DeleteMerchDevice(md);

                        transactionScope.Complete();
                    }
                }
                break;

                case DeviceTypeEnum.Clerk:
                case DeviceTypeEnum.Terminal:
                {
                    //获取终端绑定关系实体
                    Data_MerchSegment ms = MerchSegmentBusiness.GetMerchSegmentModel(device.ID);

                    using (var transactionScope = new System.Transactions.TransactionScope(TransactionScopeOption.RequiresNew))
                    {
                        DeviceBusiness.UpdateDevice(device);
                        ret = MerchSegmentBusiness.DeleteMerchSegment(ms);

                        transactionScope.Complete();
                    }
                }
                break;
                }

                if (ret)
                {
                    DeviceStatusBusiness.SetDeviceState(device.Token, DeviceStatusEnum.未激活.ToDescription());
                }

                return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.T, ""));
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Example #34
0
        public object getDeviceInfo(Dictionary <string, object> dicParas)
        {
            try
            {
                string errMsg      = string.Empty;
                string mobileToken = dicParas.ContainsKey("mobileToken") ? dicParas["mobileToken"].ToString() : string.Empty;
                string deviceToken = dicParas.ContainsKey("deviceToken") ? dicParas["deviceToken"].ToString() : string.Empty;
                string routerToken = dicParas.ContainsKey("routerToken") ? dicParas["routerToken"].ToString().Trim().ToLower() : string.Empty;

                Base_MerchInfo merch = MerchBusiness.GetMerchModel(mobileToken);
                if (merch.IsNull())
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "用户令牌无效"));
                }

                Base_DeviceInfo device = DeviceBusiness.GetDeviceModel(deviceToken);
                if (device.IsNull())
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "设备令牌无效"));
                }

                string status = DeviceStatusBusiness.GetDeviceState(device.Token);

                //当前设备类型
                DeviceTypeEnum currDeviceType = (DeviceTypeEnum)device.DeviceType;

                DeviceInfoModel model = new DeviceInfoModel();
                model.Router      = new Router();
                model.Group       = new Group();
                model.deviceName  = device.DeviceName ?? device.SN;
                model.deviceToken = device.Token;
                model.deviceType  = currDeviceType.ToDescription();
                model.deviceSN    = device.SN;
                model.status      = DeviceStatusBusiness.GetDeviceState(device.Token);


                //设备未绑定
                if (device.MerchID == 0 || device.MerchID.IsNull())
                {
                    model.BindState = (int)DeviceBoundStateEnum.NotBound;
                    return(ResponseModelFactory <DeviceInfoModel> .CreateModel(isSignKeyReturn, model));
                }

                //判断设备绑定的商户是否与当前商户一致
                if (device.MerchID != merch.ID)
                {
                    //与当前商户不一致
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "没有权限查看该设备信息"));
                }

                //Base_DeviceInfo currRouter = null;
                //if (!string.IsNullOrWhiteSpace(routerToken))
                //{
                //    currRouter = DeviceBusiness.GetDeviceModel(routerToken);
                //}

                //1.如果设备绑定的商户与当前商户一致
                //2.判断设备是否已与当前商户建立绑定关系
                switch (currDeviceType)
                {
                case DeviceTypeEnum.Router:
                    model.BindState = (int)DeviceBoundStateEnum.Bound;
                    break;

                case DeviceTypeEnum.SlotMachines:
                case DeviceTypeEnum.DepositMachine:
                {
                    //获取外设绑定关系实体
                    Data_MerchDevice md = MerchDeviceBusiness.GetMerchDeviceModel(device.ID);
                    if (md.IsNull())
                    {
                        model.BindState = (int)DeviceBoundStateEnum.NotBound;
                    }
                    else
                    {
                        //获取控制器实体
                        Base_DeviceInfo router = DeviceBusiness.GetDeviceModelById((int)md.ParentID);

                        if (router.Token.Trim().ToLower() != routerToken)
                        {
                            //设备所属控制器与当前控制器不一致
                            return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "该设备不属于当前控制器"));
                        }

                        model.BindState   = (int)DeviceBoundStateEnum.Bound;
                        model.headAddress = md.HeadAddress;
                        //控制器信息
                        model.Router.routerName  = router.DeviceName ?? router.SN;
                        model.Router.routerToken = router.Token;
                        model.Router.sn          = router.SN;
                    }
                }
                break;

                case DeviceTypeEnum.Clerk:
                case DeviceTypeEnum.Terminal:
                {
                    //获取终端绑定关系实体
                    Data_MerchSegment ms = MerchSegmentBusiness.GetMerchSegmentModel(device.ID);
                    if (ms.IsNull())
                    {
                        model.BindState = (int)DeviceBoundStateEnum.NotBound;
                    }
                    else
                    {
                        //获取控制器实体
                        Base_DeviceInfo router = DeviceBusiness.GetDeviceModelById((int)ms.ParentID);

                        if (router.Token.Trim().ToLower() != routerToken)
                        {
                            //设备所属控制器与当前控制器不一致
                            return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "该设备不属于当前控制器"));
                        }

                        model.BindState   = (int)DeviceBoundStateEnum.Bound;
                        model.headAddress = ms.HeadAddress;

                        //控制器信息
                        model.Router.routerName  = router.DeviceName ?? router.SN;
                        model.Router.routerToken = router.Token;
                        model.Router.sn          = router.SN;

                        //获取分组实体
                        Data_GameInfo group = GameBusiness.GetGameInfoModel(Convert.ToInt32(ms.GroupID));
                        model.Group.groupId   = group.GroupID;
                        model.Group.groupName = group.GroupName;
                        model.Group.groupType = ((GroupTypeEnum)(int)group.GroupType).ToDescription();
                    }
                }
                break;
                }

                //返回设备信息
                return(ResponseModelFactory <DeviceInfoModel> .CreateModel(isSignKeyReturn, model));
            }
            catch (Exception e)
            {
                throw e;
            }
        }