コード例 #1
0
        public async Task <ActionResult> Create(DeviceVM vm)
        {
            var uniqueIdGenerator = _client.GetGrain <IUniqueIdGenerator>(vm.Entity.ProductId);

            var newId = await uniqueIdGenerator.NewId();

            vm.Entity.ID = newId;

            if (!ModelState.IsValid)
            {
                return(PartialView(vm));
            }
            else
            {
                vm.DoAdd();
                if (!ModelState.IsValid)
                {
                    vm.DoReInit();
                    return(PartialView(vm));
                }
                else
                {
                    return(FFResult().CloseDialog().RefreshGrid());
                }
            }
        }
コード例 #2
0
        public async Task <IActionResult> PushEvent(string EventName, int DeviceID)
        {
            var user = await _userManager.GetUserAsync(HttpContext.User);

            Events evnt = new Events();

            evnt.DeviceID  = DeviceID;
            evnt.EventName = EventName;
            evnt.Initialize();

            AdminUser au = new AdminUser();

            au.getDevices(user.FBToken);
            DeviceVM device = _mapper.Map <DeviceVM>(db.Devices.FirstOrDefault(d => d.Id == DeviceID));

            device.SetEventToBeSend(evnt);

            FirebaseSetting fbs = new FirebaseSetting();

            fbs = db.FirebaseSettings.FirstOrDefault();
            FirebaseSupportService fbss = new FirebaseSupportService(fbs, _mapper);

            fbss.MaketheAPICall(device);

            return(View(evnt));
        }
コード例 #3
0
        public List <DeviceVM> GetAllDevices()
        {
            // Proci po svakom uređaju i dohvatiti pripadajućeg korisnika i proizvođača

            var devices = _db.Devices
                          .Include(x => x.User)
                          .ToList();
            var resultList = new List <DeviceVM>();

            foreach (var device in devices)
            {
                DeviceVM vm = new DeviceVM()
                {
                    Imei             = device.Imei,
                    Model            = device.Model,
                    PhoneNumber      = device.PhoneNumber,
                    Id               = device.Id,
                    Price            = device.Price,
                    ManufacturerName = device.Manufacturer.Name
                };

                if (device.UserId.HasValue)
                {
                    vm.UserName = device.User.FirstName + " " + device.User.LastName;
                }

                resultList.Add(vm);
            }

            return(resultList);
        }
コード例 #4
0
        // PUT api/pushdata/5
        //public void Put(int id, [FromBody]string value) {

        //}

        // DELETE api/pushdata/5
        public void Delete(DeviceVM myDevice)
        {
            bool continuometodo = true;

            if (string.IsNullOrEmpty(myDevice.UUID))
            {
                continuometodo = false;
            }
            PushNotificationRecord devicetostore = new PushNotificationRecord();

            devicetostore.DataModifica = DateTime.Now;
            switch (myDevice.Device)
            {
            case "Apple":
                if (myDevice.Token.Length > 100)
                {
                    devicetostore.Device = TipoDispositivo.AppleFCM;
                }
                else
                {
                    devicetostore.Device = TipoDispositivo.Apple;
                }
                break;

            case "Android":
                devicetostore.Device = TipoDispositivo.Android;
                break;

            case "WindowsMobile":
                devicetostore.Device = TipoDispositivo.WindowsMobile;
                break;

            default:
                continuometodo = false;

                break;
            }
            if (continuometodo)
            {
                try {
                    devicetostore.Validated    = false;
                    devicetostore.Language     = myDevice.Language;
                    devicetostore.Produzione   = myDevice.Produzione;
                    devicetostore.Token        = myDevice.Token;
                    devicetostore.UUIdentifier = myDevice.UUID;
                    _pushNotificationService.StorePushNotification(devicetostore);
                }
                catch (Exception ex) {
                    HttpResponseMessage message = new HttpResponseMessage(System.Net.HttpStatusCode.InternalServerError);
                    message.Content = new StringContent(ex.Message);
                    throw new HttpResponseException(message);
                }
            }
            else
            {
                HttpResponseMessage message = new HttpResponseMessage(System.Net.HttpStatusCode.InternalServerError);
                message.Content = new StringContent("No Device type or UUID specified.");
                throw new HttpResponseException(message);
            }
        }
コード例 #5
0
        public void DeleteTest()
        {
            Device v = new Device();

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                v.ID        = "44tvMxOP9";
                v.ProductId = AddProduct();
                context.Set <Device>().Add(v);
                context.SaveChanges();
            }

            PartialViewResult rv = (PartialViewResult)_controller.Delete(v.ID.ToString());

            Assert.IsInstanceOfType(rv.Model, typeof(DeviceVM));

            DeviceVM vm = rv.Model as DeviceVM;

            v         = new Device();
            v.ID      = vm.Entity.ID;
            vm.Entity = v;
            _controller.Delete(v.ID.ToString(), null);

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                Assert.AreEqual(context.Set <Device>().Count(), 0);
            }
        }
コード例 #6
0
        public void EditTest()
        {
            Device v = new Device();

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                v.ID        = "44tvMxOP9";
                v.ProductId = AddProduct();
                context.Set <Device>().Add(v);
                context.SaveChanges();
            }

            PartialViewResult rv = (PartialViewResult)_controller.Edit(v.ID.ToString());

            Assert.IsInstanceOfType(rv.Model, typeof(DeviceVM));

            DeviceVM vm = rv.Model as DeviceVM;

            v    = new Device();
            v.ID = vm.Entity.ID;

            vm.Entity = v;
            vm.FC     = new Dictionary <string, object>();

            vm.FC.Add("Entity.ID", "");
            vm.FC.Add("Entity.ProductId", "");
            _controller.Edit(vm);

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                var data = context.Set <Device>().FirstOrDefault();
            }
        }
コード例 #7
0
        public DeviceVM GetDeviceVMById(int deviceId)
        {
            var device = _db.Devices.Where(x => x.Id == deviceId).FirstOrDefault();

            if (device == null)
            {
                //Log something
                return(null);
            }

            DeviceVM vm = new DeviceVM()
            {
                Imei             = device.Imei,
                Model            = device.Model,
                PhoneNumber      = device.PhoneNumber,
                Id               = device.Id,
                Price            = device.Price,
                ManufacturerName = device.Manufacturer.Name,
                ManufacturerId   = device.ManufacturerId
            };

            if (device.UserId.HasValue)
            {
                vm.UserId   = device.UserId;
                vm.UserName = device.User.FirstName + " " + device.User.LastName;
            }

            return(vm);
        }
コード例 #8
0
        // PUT: api/Device/5
        public DeviceGridVM Put(DeviceVM dev)
        {
            var mappedDevice = DeviceMapper.MapToDev(dev);

            _deviceService.Edit(mappedDevice);
            return(DeviceMapper.MapToVM(mappedDevice));
        }
コード例 #9
0
        public DeviceGridVM Post([FromBody] DeviceVM devVm)
        {
            var newDev = DeviceMapper.MapToDev(devVm);

            newDev.UserEmail = User.Identity.Name;
            _deviceService.Add(newDev);
            return(DeviceMapper.MapToVM(newDev));
        }
コード例 #10
0
        public HttpResponseMessage Put(DeviceVM myDevice)
        {
            bool continuometodo = true;

            if (string.IsNullOrEmpty(myDevice.UUID))
            {
                continuometodo = false;
            }
            PushNotificationRecord devicetostore = new PushNotificationRecord();

            devicetostore.DataModifica = DateTime.Now;
            switch (myDevice.Device)
            {
            case "Apple":
                devicetostore.Device = TipoDispositivo.Apple;
                break;

            case "Android":
                devicetostore.Device = TipoDispositivo.Android;
                break;

            case "WindowsMobile":
                devicetostore.Device = TipoDispositivo.WindowsMobile;
                break;

            default:
                continuometodo = false;
                break;
            }
            if (continuometodo)
            {
                try {
                    string host = HttpContext.Current.Request.Url.Host;

                    devicetostore.Validated    = true;
                    devicetostore.Language     = myDevice.Language;
                    devicetostore.Produzione   = myDevice.Produzione;
                    devicetostore.Token        = myDevice.Token;
                    devicetostore.UUIdentifier = myDevice.UUID;
                    _pushNotificationService.StorePushNotification(devicetostore);
                    HttpResponseMessage message = new HttpResponseMessage(System.Net.HttpStatusCode.OK);
                    //// response.Headers.Location = new Uri(Request.RequestUri.ToString());
                    // message.Content = new StringContent( "OK");
                    //  throw new HttpResponseException(
                    return(message);
                } catch (Exception ex) {
                    HttpResponseMessage message = new HttpResponseMessage(System.Net.HttpStatusCode.InternalServerError);
                    message.Content = new StringContent(ex.Message);
                    throw new HttpResponseException(message);
                }
            }
            else
            {
                HttpResponseMessage message = new HttpResponseMessage(System.Net.HttpStatusCode.InternalServerError);
                message.Content = new StringContent("No Device type or UUID specified.");
                throw new HttpResponseException(message);
            }
        }
コード例 #11
0
        private void OnBackPressed(object sender, BackPressedEventArgs e)
        {
            if (this.Frame.CanGoBack)
            {
                DeviceVM.UnregisterVMFromModel();
                this.Frame.GoBack();
                e.Handled = true;

                // Unregister notifications off the UI thrad
                Utilities.RunFuncAsTask(GlobalSettings.SelectedDevice.UnregisterNotificationsAsync);
            }
        }
コード例 #12
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            // Reset list choice
            if (_serviceListBox != null)
            {
                _serviceListBox.SelectedIndex = -1;
            }

            // These must be initialized before the UI loads
            DeviceVM.Initialize(GlobalSettings.SelectedDevice);
            ServicesVM.Initialize(GlobalSettings.SelectedDevice.ServiceModels);

            // Complete remaining initialization without blocking this callback
            Utilities.RunFuncAsTask(GlobalSettings.SelectedDevice.RegisterNotificationsAsync);
        }
コード例 #13
0
 private async Task <SingleDeviceScanVM> InitializeAsync(Device dev, DeviceBatchContext context)
 {
     return(await Task.Run(() =>
     {
         TheDeviceVM = new DeviceVM(dev, ctx);
         RunVoltageSweepCommand = AsyncCommand.Create(token => ScanPixelAndProcessData(token));
         TheLJVScanSummaryVM = new LJVScanSummaryVM(ctx);
         TheLJVScanSummaryVM.TheLJVScanSummary.Device = ctx.Devices.Where(x => x.DeviceId == TheDeviceVM.TheDevice.DeviceId).First();
         TheLJVScanSummaryVM.TheLJVScanSummary.TestCondition = TheScanSpec.TestCondition;
         string bts = ConfigurationManager.AppSettings.Get("BatchTestSystem");
         if (bts == "BTS2")
         {
             TheImagingControl = InstrumentService.LJVScanCoordinator.TheImagingControl;
         }
         return this;
     }));
 }
コード例 #14
0
 private async Task <SingleDeviceScanVM> ManualSweepInitializeAsync()
 {
     return(await Task.Run(() =>
     {
         InstrumentService.LJVScanCoordinator.PurgeSubscribers();
         TheDeviceVM = new DeviceVM();
         TheLJVScanSummaryVM = new LJVScanSummaryVM();
         TheLJVScanSummaryVM.TheLJVScanSummary.Device = TheDeviceVM.TheDevice;
         RunVoltageSweepCommand = AsyncCommand.Create(token => ScanPixelAndProcessData(token));
         ScanAllPixelsCommand = AsyncCommand.Create(token => ScanAllPixels(token));
         //InstrumentService.LJVScanCoordinator.VoltageSweepFinished += InstrumentService_VoltageSweepFinished;
         SelectedPixel = theDeviceVM.PixelsDict["SiteA"];
         string bts = ConfigurationManager.AppSettings.Get("BatchTestSystem");
         if (bts == "BTS2")
         {
             TheImagingControl = InstrumentService.LJVScanCoordinator.TheImagingControl;
         }
         return this;
     }));
 }
コード例 #15
0
 public ActionResult Edit(DeviceVM vm)
 {
     if (!ModelState.IsValid)
     {
         return(PartialView(vm));
     }
     else
     {
         vm.DoEdit();
         if (!ModelState.IsValid)
         {
             vm.DoReInit();
             return(PartialView(vm));
         }
         else
         {
             return(FFResult().CloseDialog().RefreshGridRow(vm.Entity.ID));
         }
     }
 }
コード例 #16
0
        public void CreateTest()
        {
            PartialViewResult rv = (PartialViewResult)_controller.Create();

            Assert.IsInstanceOfType(rv.Model, typeof(DeviceVM));

            DeviceVM vm = rv.Model as DeviceVM;
            Device   v  = new Device();

            v.ID        = "44tvMxOP9";
            v.ProductId = AddProduct();
            vm.Entity   = v;
            _controller.Create(vm);

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                var data = context.Set <Device>().FirstOrDefault();

                Assert.AreEqual(data.ID, "44tvMxOP9");
            }
        }
コード例 #17
0
        public static Device MapToDev(DeviceVM devVm)
        {
            var dev = new Device();

            dev.IpAddress = devVm.IpAddress;
            dev.IpType    = devVm.IpType;
            dev.Location  = new Location()
            {
                Id = devVm.LocationId
            };
            dev.LoginEnablePassword = devVm.LoginEnablePassword;
            dev.LoginIpAddress      = devVm.LoginIpAddress;
            dev.LoginPassword       = devVm.LoginPassword;
            dev.LoginUserName       = devVm.LoginUserName;
            dev.Manufacturer        = new Manufacturer()
            {
                Id = devVm.ManufacturerId
            };
            dev.Model = new Model()
            {
                Id = devVm.ModelId
            };
            dev.NIC1DefaultGateway = devVm.NIC1DefaultGateway;
            dev.NIC1IpAddress      = devVm.NIC1NATIpAddress;
            dev.NIC1SubNetMask     = devVm.NIC1SubNetMask;
            dev.NIC2DefaultGateway = devVm.NIC2DefaultGateway;
            dev.NIC1NATIpAddress   = devVm.NIC1NATIpAddress;
            dev.NIC2IpAddress      = devVm.NIC2IpAddress;
            dev.NIC2SubNetMask     = devVm.NIC2SubNetMask;
            dev.NickName           = devVm.NickName;
            dev.Policy             = new Policy()
            {
                Id = devVm.PolicyId
            };
            dev.ZipCode = devVm.ZipCode;
            dev.Id      = devVm.Id;
            return(dev);
        }
コード例 #18
0
        public int Add(DeviceVM model)
        {
            var entity = Mapper.Map <Device>(model);

            return(_propertyValueRepository.Add(entity));
        }