public UrlServiceSubscription(DeviceService service, string uri, JsonObject payload, bool isWebOs,
     ResponseListener listener)
     : base(service, uri, payload, listener)
 {
     if (isWebOs)
         HttpMethod = "subscribe";
 }
Esempio n. 2
0
 public DeviceService getDeviceService()
 {
     if (deviceService == null)
     {
         deviceService = new DeviceServiceImpl();
     }
     return deviceService;
 }
        public WebOsWebAppSession(LaunchSession launchSession, DeviceService service)
            : base(launchSession, service)
        {
            uid = 0;
            mActiveCommands = new ConcurrentDictionary<String, ServiceCommand>();
            Connected = false;

            Service = (WebOstvService) service;
            mSocketListener = new WebOstvServiceSocketClientListener(this);
        }
Esempio n. 4
0
        public async Task<XDocument> SendCommandAsync(string baseUrl, 
            DeviceService service, 
            string command, 
            string postData, 
            bool logRequest = true,
            string header = null)
        {
            var response = await PostSoapDataAsync(NormalizeServiceUrl(baseUrl, service.ControlUrl), "\"" + service.ServiceType + "#" + command + "\"", postData, header, logRequest)
                .ConfigureAwait(false);

            using (var stream = response.Content)
            {
                using (var reader = new StreamReader(stream, Encoding.UTF8))
                {
                    return XDocument.Parse(reader.ReadToEnd(), LoadOptions.PreserveWhitespace);
                }
            }
        }
        public DeviceSimulator(StatelessServiceContext context)
            : base(context)
        {
            var configurationPackage            = Context.CodePackageActivationContext.GetConfigurationPackageObject("Config");
            var iotHubConnectionStringParameter = configurationPackage.Settings.Sections["ConnectionStrings"].Parameters["IoTHubConnectionString"];
            var iotHubConnectionString          = iotHubConnectionStringParameter.Value;

            var storageAccouuntConnectionStringParameter = configurationPackage.Settings.Sections["ConnectionStrings"].Parameters["StorageAccountConnectionString"];
            var storageAccountConnectionString           = storageAccouuntConnectionStringParameter.Value;

            var bytes          = Context.InitializationData;
            var json           = Encoding.ASCII.GetString(bytes);
            var simulationItem = JsonConvert.DeserializeObject <SimulationItem>(json);

            var storageService = new StorageService(context, storageAccountConnectionString);
            var deviceService  = new DeviceService(context, iotHubConnectionString, simulationItem.DeviceName, simulationItem.DeviceType);

            scriptEngine = new CSharpScriptEngine(storageService, deviceService);
        }
Esempio n. 6
0
        public async void DeviceActionsByDeviceId_Exists()
        {
            var mock    = new ServiceMockFacade <IDeviceService, IDeviceRepository>();
            var records = new List <DeviceAction>();

            records.Add(new DeviceAction());
            mock.RepositoryMock.Setup(x => x.DeviceActionsByDeviceId(default(int), It.IsAny <int>(), It.IsAny <int>())).Returns(Task.FromResult(records));
            var service = new DeviceService(mock.LoggerMock.Object,
                                            mock.MediatorMock.Object,
                                            mock.RepositoryMock.Object,
                                            mock.ModelValidatorMockFactory.DeviceModelValidatorMock.Object,
                                            mock.DALMapperMockFactory.DALDeviceMapperMock,
                                            mock.DALMapperMockFactory.DALDeviceActionMapperMock);

            List <ApiDeviceActionServerResponseModel> response = await service.DeviceActionsByDeviceId(default(int));

            response.Should().NotBeEmpty();
            mock.RepositoryMock.Verify(x => x.DeviceActionsByDeviceId(default(int), It.IsAny <int>(), It.IsAny <int>()));
        }
Esempio n. 7
0
        public async void All_ShouldReturnRecords()
        {
            var mock    = new ServiceMockFacade <IDeviceService, IDeviceRepository>();
            var records = new List <Device>();

            records.Add(new Device());
            mock.RepositoryMock.Setup(x => x.All(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <string>())).Returns(Task.FromResult(records));
            var service = new DeviceService(mock.LoggerMock.Object,
                                            mock.MediatorMock.Object,
                                            mock.RepositoryMock.Object,
                                            mock.ModelValidatorMockFactory.DeviceModelValidatorMock.Object,
                                            mock.DALMapperMockFactory.DALDeviceMapperMock,
                                            mock.DALMapperMockFactory.DALDeviceActionMapperMock);

            List <ApiDeviceServerResponseModel> response = await service.All();

            response.Should().HaveCount(1);
            mock.RepositoryMock.Verify(x => x.All(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <string>()));
        }
        /// <summary>
        /// Binds the devices.
        /// </summary>
        private void BindDevices()
        {
            int?kioskDeviceTypeValueId = DefinedValueCache.GetId(Rock.SystemGuid.DefinedValue.DEVICE_TYPE_CHECKIN_KIOSK.AsGuid());

            var rockContext = new RockContext();

            DeviceService deviceService = new DeviceService(rockContext);
            var           devices       = deviceService.Queryable().AsNoTracking().Where(d => d.DeviceTypeValueId == kioskDeviceTypeValueId && d.IsActive == true)
                                          .OrderBy(a => a.Name)
                                          .Select(a => new
            {
                a.Id,
                a.Name
            }).ToList();

            lbDevices.Items.Clear();
            lbDevices.Items.Add(new ListItem());
            lbDevices.Items.AddRange(devices.Select(a => new ListItem(a.Name, a.Id.ToString())).ToArray());
        }
        public static async Task <IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req,
            ILogger log)
        {
            // localhost:7071/api/sendmessagetodevice?targetdeviceid=consoleapp&message=dettaarmeddelandet
            string targetDeviceId = req.Query["targetdeviceid"];
            string message        = req.Query["message"];
            //post body = { "targetdeviceid":"consoleapp", "message":"Detta är ett meddelande"
            string requestBody = await new StreamReader(req.Body).ReadToEndAsync();

            var data = JsonConvert.DeserializeObject <BodyMessageModel>(requestBody);

            targetDeviceId = targetDeviceId ?? data?.TargetDeviceId;
            message        = message ?? data?.Message;

            await DeviceService.SendMessageToDeviceAsync(serviceClient, targetDeviceId, message);

            return(new OkResult());
        }
Esempio n. 10
0
        public void RunWithoutAddAlarmTest()
        {
            //initialize
            Mock <IDeviceRepository>    deviceRepoMock    = new Mock <IDeviceRepository>();
            Mock <ITelemetryRepository> telemetryRepoMock = new Mock <ITelemetryRepository>();
            Mock <IFreezeRepository>    freezeReop        = new Mock <IFreezeRepository>();

            alarmsList = new List <Alarm>
            {
                new Alarm
                {
                    Id           = "1",
                    AlarmType    = Alarm.Type.CommuniationFailure,
                    AlarmGravity = Alarm.Gravity.Information,
                    Description  = "",
                    IsActive     = true,
                    DeviceId     = "1",
                    OccuredAt    = DateTime.UtcNow,
                    SiteId       = "1"
                },
            };
            deviceList[0].Alarms = alarmsList;


            int minMin = 1 * 60 + 5;
            int minMax = 2 * 60 + 5;

            deviceRepoMock.Setup(o => o.GetFailsCommunicationBetween(minMin, minMax)).Returns(deviceList);

            DeviceService       deviceService       = new DeviceService(deviceRepoMock.Object, telemetryRepoMock.Object);
            AlarmService        alarmService        = new AlarmService(deviceRepoMock.Object, freezeReop.Object);
            NotificationService notificationService = new NotificationService(deviceRepoMock.Object);
            Mock <ILogger>      logger = new Mock <ILogger>();

            CommunicationStateService communicationStateService = new CommunicationStateService(deviceService, alarmService, notificationService, logger.Object);

            //execute
            communicationStateService.Run(1, 2, Alarm.Gravity.Information);

            //tests
            deviceRepoMock.Verify(o => o.UpdateStatusAlarm("1", It.IsAny <Alarm>()), Times.Never);
            deviceRepoMock.Verify(o => o.AddAlarm("1", It.IsAny <Alarm>()), Times.Never);
        }
Esempio n. 11
0
        public async void Get()
        {
            var mock   = new ServiceMockFacade <IDeviceRepository>();
            var record = new Device();

            mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(record));
            var service = new DeviceService(mock.LoggerMock.Object,
                                            mock.RepositoryMock.Object,
                                            mock.ModelValidatorMockFactory.DeviceModelValidatorMock.Object,
                                            mock.BOLMapperMockFactory.BOLDeviceMapperMock,
                                            mock.DALMapperMockFactory.DALDeviceMapperMock,
                                            mock.BOLMapperMockFactory.BOLDeviceActionMapperMock,
                                            mock.DALMapperMockFactory.DALDeviceActionMapperMock);

            ApiDeviceResponseModel response = await service.Get(default(int));

            response.Should().NotBeNull();
            mock.RepositoryMock.Verify(x => x.Get(It.IsAny <int>()));
        }
        public DeviceServiceTests()
        {
            // Build Device
            Device device = new DeviceBuilder()
                            .WithId("27be25a2-1b69-4476-a90f-f80498f5e2ec")
                            .WithTitle("Raspberry3")
                            .Build();

            // Build Device list
            List <Device> devicesList = new List <Device> {
                device
            };

            // Build device service
            service = new DeviceServiceBuilder()
                      .WithRepositoryMock(devicesList, device)
                      .WithUnitOfWorkSetup()
                      .Build();
        }
Esempio n. 13
0
        public async Task <XDocument> SendCommandAsync(string baseUrl,
                                                       DeviceService service,
                                                       string command,
                                                       string postData,
                                                       bool logRequest = true,
                                                       string header   = null)
        {
            var cancellationToken = CancellationToken.None;

            var url = NormalizeServiceUrl(baseUrl, service.ControlUrl);

            using (var response = await PostSoapDataAsync(url, '\"' + service.ServiceType + '#' + command + '\"', postData, header, logRequest, cancellationToken)
                                  .ConfigureAwait(false))
                using (var stream = response.Content)
                    using (var reader = new StreamReader(stream, Encoding.UTF8))
                    {
                        return(XDocument.Parse(reader.ReadToEnd(), LoadOptions.PreserveWhitespace));
                    }
        }
Esempio n. 14
0
        /// <summary>
        /// Handles when the device type selection is changed.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        protected void ddlDeviceType_SelectedIndexChanged(object sender, EventArgs e)
        {
            Device device = null;

            int deviceId = hfDeviceId.ValueAsInt();

            if (deviceId != 0)
            {
                device = new DeviceService(new RockContext()).Get(deviceId);
            }

            if (device == null)
            {
                device = new Device();
            }

            SetPrinterSettingsVisibility();
            UpdateControlsForDeviceType(device);
        }
        private async Task <IActionResult> UpdateDevice(UpdateDeviceRequest updateDeviceRequest)
        {
            var options = new DbContextOptionsBuilder <Context>()
                          .UseInMemoryDatabase(databaseName: "Device")
                          .Options;



            // Run the test against one instance of the context
            using (var context = new Context(options))
            {
                var repository = new DeviceRepository(context, AutomapperSingleton.Mapper);
                var service    = new DeviceService(repository, AutomapperSingleton.Mapper);
                var controller = new DeviceController(service);

                Mock <HttpRequest> mockCreateRequest = MockHttpRequest.CreateMockRequest(updateDeviceRequest);
                return(await controller.UpdateDeviceAsync(mockCreateRequest.Object, _logger)); //as GridController;
            }
        }
Esempio n. 16
0
        /// <summary>
        /// Handles the Click event of the btnSave control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        protected void btnSave_Click(object sender, EventArgs e)
        {
            Device           Device;
            DeviceService    DeviceService    = new DeviceService();
            AttributeService attributeService = new AttributeService();

            int DeviceId = int.Parse(hfDeviceId.Value);

            if (DeviceId == 0)
            {
                Device = new Device();
                DeviceService.Add(Device, CurrentPersonId);
            }
            else
            {
                Device = DeviceService.Get(DeviceId);
            }

            Device.Name              = tbName.Text;
            Device.Description       = tbDescription.Text;
            Device.IPAddress         = tbIpAddress.Text;
            Device.DeviceTypeValueId = ddlDeviceType.SelectedValueAsInt().Value;
            Device.PrintToOverride   = (PrintTo)System.Enum.Parse(typeof(PrintTo), ddlPrintTo.SelectedValue);
            Device.PrinterDeviceId   = ddlPrinter.SelectedValueAsInt();
            Device.PrintFrom         = (PrintFrom)System.Enum.Parse(typeof(PrintFrom), ddlPrintFrom.SelectedValue);

            if (Device.Location == null)
            {
                Device.Location = new Location();
            }
            Device.Location.GeoPoint = gpGeoPoint.SelectedValue;
            Device.Location.GeoFence = gpGeoFence.SelectedValue;

            if (!Device.IsValid)
            {
                // Controls will render the error messages
                return;
            }

            DeviceService.Save(Device, CurrentPersonId);

            NavigateToParentPage();
        }
        public static async Task <IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req,
            ILogger log)
        {
            string targetDeviceId = req.Query["targetdevice"];
            string message        = req.Query["message"];


            string requestBody = await new StreamReader(req.Body).ReadToEndAsync();

            var data = JsonConvert.DeserializeObject <BodyMessageModel>(requestBody);

            targetDeviceId = targetDeviceId ?? data?.TargetDeviceId;
            message        = message ?? data?.Messege;

            await DeviceService.SendMessageToDeviceAsync(serviceClient, targetDeviceId, message);

            return(new OkObjectResult(message));
        }
Esempio n. 18
0
 public ActionResult Create(DeviceViewModel model)
 {
     if (ModelState.IsValid)
     {
         OperationResult result = DeviceService.Insert(model);
         if (result.ResultType == OperationResultType.Success)
         {
             return(Json(result));
         }
         else
         {
             return(PartialView(model));
         }
     }
     else
     {
         return(PartialView(model));
     }
 }
Esempio n. 19
0
        /// <summary>
        /// 单个设备的年月发电量图表数据
        /// </summary>
        /// <param name="userId">用户id</param>
        /// <param name="startYM">开始年月</param>
        /// <param name="endYM">截止年月</param>
        /// <param name="chartType">图表类型</param>
        /// <returns></returns>
        public ActionResult DeviceYearMMChart(int dId, string startYM, string endYM, string chartType)
        {
            string reportData = string.Empty;

            if (string.IsNullOrEmpty(chartType))
            {
                chartType = ChartType.column;
            }
            Device device = DeviceService.GetInstance().get(dId);

            if (device != null)
            {
                string unit = "kWh";
                //取得用户年度发电量图表数据
                ChartData chartData = DeviceChartService.GetInstance().YearMMChartByDevice(device, 1.0F, string.Format(LanguageUtil.getDesc("DEVICEYEAR_CHART_NAME"), device.fullName), startYM, endYM, chartType, unit);
                reportData = JsonUtil.convertToJson(chartData, typeof(ChartData));
            }
            return(Content(reportData));
        }
Esempio n. 20
0
        public void InitConfig(string type)
        {
            // 初始化配置文件信息
            foreach (string workType in InitConfigInfo.WorkGroups.Keys)
            {
                if (workType == type)
                {
                    WorkGroupElement workGroup = InitConfigInfo.WorkGroups[workType];
                    for (int i = 0; i < workGroup.Devices.Count; i++)
                    {
                        DeviceElement deviceElement = workGroup.Devices[i];
                        dictionaryDevices.Add(deviceElement.DeviceNumber, deviceElement);
                    }
                }
            }

            this.OPCServerIP   = ConfigurationManager.AppSettings["OPCServerIP"];
            this.OPCServerPort = ConfigurationManager.AppSettings["OPCServerPort"];
            this.localHostIP   = ConfigurationManager.AppSettings["LocalHostIP"];
            this.localHostPort = ConfigurationManager.AppSettings["LocalHostPort"];
            if (InitConfigInfo.PingIpOrDomainName(OPCServerIP, localHostIP, dictionaryDevices["1"].PLCip))
            {
                this.service = DeviceService.Register(1, localHostIP, int.Parse(localHostPort), OPCServerIP, int.Parse(OPCServerPort));
                this.device  = new PLCDevice(dictionaryDevices["1"].PLCip, DeviceType.Siemens_S7_1200);

                this.Title = string.Format("{0}             本机IP:{1}  本机端口:{2}             远程IP:{3}  远程端口:{4}          PLCIP地址:{5}", "PLC监听", localHostIP, localHostPort, OPCServerIP, OPCServerPort, dictionaryDevices["1"].PLCip);



                address = new PLCAddress[dictionaryDevices.Count];
                for (int i = 0; i < dictionaryDevices.Count; i++)
                {
                    address[i] = device.Add(dictionaryDevices[(i + 1).ToString()].PLCAddress);
                }
                CommandResult res = service.ListenDevice(device);
                ReadPLCValue();
            }
            else
            {
                MessageBox.Show("网络错误,请检查网络", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
                this.Close();
            }
        }
Esempio n. 21
0
        private void EnableSelection()
        {
            if (MainPivot.SelectedItem.Equals(CloudDrivePivot))
            {
                this.CloudDriveExplorer.EnableSelection();
            }

            if (MainPivot.SelectedItem.Equals(RubbishBinPivot))
            {
                this.RubbishBinExplorer.EnableSelection();
            }

            if (MainPivot.SelectedItem.Equals(CameraUploadsPivot))
            {
                this.GridViewCameraUploads.SelectionMode =
                    DeviceService.GetDeviceType() == DeviceFormFactorType.Desktop ?
                    ListViewSelectionMode.Extended : ListViewSelectionMode.Single;
            }
        }
Esempio n. 22
0
 public async Task <XDocument> SendCommandAsync(string baseUrl,
                                                DeviceService service,
                                                string command,
                                                string postData,
                                                bool logRequest = true,
                                                string header   = null)
 {
     using (var response = await PostSoapDataAsync(NormalizeServiceUrl(baseUrl, service.ControlUrl), "\"" + service.ServiceType + "#" + command + "\"", postData, header, logRequest)
                           .ConfigureAwait(false))
     {
         using (var stream = response.Content)
         {
             using (var reader = new StreamReader(stream, Encoding.UTF8))
             {
                 return(XDocument.Parse(reader.ReadToEnd(), LoadOptions.PreserveWhitespace));
             }
         }
     }
 }
Esempio n. 23
0
        /// <summary>
        /// Attempts to match a known kiosk based on the IP address of the client.
        /// </summary>
        private void AttemptKioskMatchByIpOrName()
        {
            // match kiosk by ip/name.
            string ipAddress       = RockPage.GetClientIpAddress();
            bool   lookupKioskName = GetAttributeValue("EnableReverseLookup").AsBoolean(false);

            var rockContext         = new RockContext();
            var checkInDeviceTypeId = DefinedValueCache.Read(Rock.SystemGuid.DefinedValue.DEVICE_TYPE_CHECKIN_KIOSK).Id;
            var device = new DeviceService(rockContext).GetByIPAddress(ipAddress, checkInDeviceTypeId, lookupKioskName);

            string hostName       = string.Empty;
            string deviceLocation = string.Empty;

            try
            {
                hostName = Dns.GetHostEntry(ipAddress).HostName;
            }
            catch (SocketException)
            {
                hostName = "Unknown";
            }

            if (device != null)
            {
                ClearMobileCookie();
                CurrentKioskId = device.Id;

                var location = device.Locations.FirstOrDefault();
                if (location != null)
                {
                    deviceLocation = location.Name;
                }
            }
            else if (!GetAttributeValue("AllowManualSetup").AsBoolean())
            {
                maAlert.Show("This device does not match a known check-in station.", ModalAlertType.Alert);
                lbOk.Text    = @"<span class='fa fa-refresh' />";
                lbOk.Enabled = false;
            }

            lblInfo.Text = string.Format("Device IP: {0} &nbsp;&nbsp;&nbsp;&nbsp; Name: {1} &nbsp;&nbsp;&nbsp;&nbsp; Location: {2}", ipAddress, hostName, deviceLocation);
            pnlContent.Update();
        }
Esempio n. 24
0
        public static void Initialize(TestContext context)
        {
            _device = DeviceService.Create(new ConnectionConfig {
                DeviceType     = DeviceType.PAX_S300,
                ConnectionMode = ConnectionModes.TCP_IP,
                IpAddress      = "10.12.220.172",
                //IpAddress = "192.168.0.31",
                Port              = "10009",
                Timeout           = 30000,
                RequestIdProvider = new RandomIdProvider()
            });
            Assert.IsNotNull(_device);

            _device.OnMessageSent += (message) => {
                Assert.IsTrue(message.Contains(searchText), message);
            };

            var card = new CreditCardData {
                Number   = "4005554444444460",
                ExpMonth = 12,
                ExpYear  = 20,
                Cvn      = "123"
            };

            var address = new Address {
                StreetAddress1 = "1 Heartland Way",
                PostalCode     = "95124"
            };

            var response = _device.Sale(11m)
                           .WithAllowDuplicates(true)
                           .WithPaymentMethod(card)
                           .WithAddress(address)
                           .Execute();

            Assert.IsNotNull(response);
            Assert.AreEqual("00", response.ResponseCode);

            authCode          = response.AuthorizationCode;
            transactionNumber = response.TerminalRefNumber;
            referenceNumber   = response.ReferenceNumber;
        }
Esempio n. 25
0
        /// <summary>
        /// 编辑或创建设备
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonX2_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(this._device.DeviceName))
            {
                MessageBox.Show("测点名称不能为空");
                return;
            }

            if (string.IsNullOrEmpty(this._device.DeviceNum))
            {
                MessageBox.Show("测点编号不能为空");
                return;
            }

            if (string.IsNullOrEmpty(this._device.IPAddress) || string.IsNullOrEmpty(this._device.Port))
            {
                MessageBox.Show("IP或端口号不能为空");
                return;
            }

            try
            {
                if (_device.Id == 0)
                {
                    DeviceService.AddDevice(this._device);
                }
                else
                {
                    DeviceService.UpdateDevice(this._device);
                }
                if (EditComplete != null)
                {
                    EditComplete(this._device);
                }

                this.Hide();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Esempio n. 26
0
        private void BindGroupTypes(string selectedValues)
        {
            var selectedItems = selectedValues.Split(',');

            cblGroupTypes.Items.Clear();

            if (ddlKiosk.SelectedValue != None.IdValue)
            {
                var kiosk = new DeviceService().Get(Int32.Parse(ddlKiosk.SelectedValue));
                if (kiosk != null)
                {
                    cblGroupTypes.DataSource = kiosk.GetLocationGroupTypes();
                    cblGroupTypes.DataBind();
                }

                if (selectedValues != string.Empty)
                {
                    foreach (string id in selectedValues.Split(','))
                    {
                        ListItem item = cblGroupTypes.Items.FindByValue(id);
                        if (item != null)
                        {
                            item.Selected = true;
                        }
                    }
                }
                else
                {
                    if (CurrentGroupTypeIds != null)
                    {
                        foreach (int id in CurrentGroupTypeIds)
                        {
                            ListItem item = cblGroupTypes.Items.FindByValue(id.ToString());
                            if (item != null)
                            {
                                item.Selected = true;
                            }
                        }
                    }
                }
            }
        }
Esempio n. 27
0
        public Task StartAsync(CancellationToken cancellationToken)
        {
            _logger.LogInformation("Device type is {DeviceType}.", _configuration.DeviceType);

            _deviceService = _deviceServices
                             .FirstOrDefault(s => s.DeviceType == _configuration.DeviceType);

            if (_deviceService == null)
            {
                throw new Exception($"Unable to find a service for device type '{_configuration.DeviceType}'.");
            }

            _runCts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken);

            _runTask = _deviceService.RunAsync(_runCts.Token);

            _logger.LogInformation("Startup complete.");

            return(Task.CompletedTask);
        }
Esempio n. 28
0
        public SaveManagerPage(ulong titleId)
        {
            TitleID = titleId;
            InitializeComponent();

            DeviceService.TitlesChanged += RefreshSavesView;

            DeviceService.Start();

            GridView grid = ListView.View as GridView;

            if (titleId != 0) // Context is SaveManager
            {
                // The title ID is already known, so it's pointless showing the user
                RemoveColumn(grid, "Name/ID");
                RemoveColumn(grid, "Owner");
            }

            Refresh();
        }
Esempio n. 29
0
        private void OnLoaded(object sender, RoutedEventArgs e)
        {
            if (_graphicsDeviceService == null)
            {
                DeviceService.StartD3D(Window.GetWindow(this));

                // We use a render target, so the back buffer dimensions don't matter.
                _graphicsDeviceService = GraphicsDeviceService.AddRef(1, 1);
                _graphicsDeviceService.DeviceResetting += OnGraphicsDeviceServiceDeviceResetting;

                // Invoke the LoadContent event
                RaiseLoadContent(new GraphicsDeviceEventArgs(_graphicsDeviceService.GraphicsDevice));

                EnsureRenderTarget();

                CompositionTarget.Rendering += OnCompositionTargetRendering;

                _contentNeedsRefresh = true;
            }
        }
Esempio n. 30
0
        protected async Task NavigateToUri(string uri)
        {
            if (string.IsNullOrWhiteSpace(uri))
            {
                throw new ArgumentException("Value cannot be null or white space.", nameof(uri));
            }

            try
            {
                DeviceService.BeginInvokeOnMainThread(async() =>
                {
                    PlaySoundService.PlaySound(AppSoundsEnum.DigitalButton);
                    await NavigationService.NavigateAsync(uri, useModalNavigation: false);
                });
            }
            catch (Exception ex)
            {
                await HandleException(ex);
            }
        }
Esempio n. 31
0
 public IHttpActionResult AddDevice(List <base_sbxx> entitys)
 {
     try
     {
         DeviceService ds  = new DeviceService();
         var           ret = ds.Add(entitys);
         if (ret != null)
         {
             return(Json(new { code = 1, msg = "数据保成功" }));
         }
         else
         {
             return(Json(new { code = 0, msg = "数据保存失败" }));
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Esempio n. 32
0
 public IHttpActionResult EditDevice(base_sbxx entity)
 {
     try
     {
         DeviceService ds   = new DeviceService();
         int           isok = ds.Modify(entity);
         if (isok > 0)
         {
             return(Json(new { code = 1, msg = "数据修改成功" }));
         }
         else
         {
             return(Json(new { code = 0, msg = "数据修改失败" }));
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Esempio n. 33
0
        /// <summary>
        /// 取得设备某个测点的日变化曲线
        /// </summary>
        /// <param name="dId"></param>
        /// <param name="startYYYYMMDDHH"></param>
        /// <param name="endYYYYMMDDHH"></param>
        /// <param name="chartType"></param>
        /// <param name="monitorCode"></param>
        /// <returns></returns>
        public ActionResult MonitorDayChart(int dId, string startYYYYMMDDHH, string endYYYYMMDDHH, string chartType, int monitorCode, int intervalMins)
        {
            if (string.IsNullOrEmpty(chartType))
            {
                chartType = ChartType.column;
            }
            Device device = DeviceService.GetInstance().get(dId);
            //获得报表js代码
            MonitorType mt         = MonitorType.getMonitorTypeByCode(monitorCode);
            string      unit       = mt.getMonitorFirstUnitByCode();
            string      chartName  = string.Format(LanguageUtil.getDesc("MONITOR_DAY_CHAR_NAME"), mt.name);
            string      reportCode = string.Empty;

            if (device != null)
            {
                Cn.Loosoft.Zhisou.SunPower.Common.ChartData chartData = DeviceChartService.GetInstance().DayChart(device, chartName, startYYYYMMDDHH, endYYYYMMDDHH, chartType, unit, monitorCode, intervalMins);
                reportCode = JsonUtil.convertToJson(chartData, typeof(Cn.Loosoft.Zhisou.SunPower.Common.ChartData));
            }
            return(Content(reportCode));
        }
Esempio n. 34
0
        public ActionResult PRMonthDDChart(int dId, int pId, string startYYYYMMDD, string endYYYYMMDD)
        {
            String reportCode = "";

            if (dId > 0)
            {
                Plant  plant        = PlantService.GetInstance().GetPlantInfoById(pId);
                Device invertDevice = DeviceService.GetInstance().get(dId);
                //取得环境监测仪
                Device    detetorDevice = plant.getDetectorWithRenderSunshine();
                ChartData chartData     = DeviceChartService.GetInstance().MonthDDRPChartBypList(invertDevice, detetorDevice, LanguageUtil.getDesc("MONTHLY_PR_PERFORMANCE_CHART_NAME"), startYYYYMMDD, endYYYYMMDD, ChartType.column);
                reportCode = JsonUtil.convertToJson(chartData, typeof(ChartData));
            }
            else
            {
                return(Content("Error:"));
            }

            return(Content(reportCode));
        }
Esempio n. 35
0
        public async Task<XDocument> SendCommandAsync(string baseUrl, 
            DeviceService service, 
            string command, 
            string postData, 
            string header = null)
        {
            var serviceUrl = service.ControlUrl;
            if (!serviceUrl.StartsWith("/"))
                serviceUrl = "/" + serviceUrl;

            var response = await PostSoapDataAsync(baseUrl + serviceUrl, "\"" + service.ServiceType + "#" + command + "\"", postData, header)
                .ConfigureAwait(false);

            using (var stream = response.Content)
            {
                using (var reader = new StreamReader(stream, Encoding.UTF8))
                {
                    return XDocument.Parse(reader.ReadToEnd(), LoadOptions.PreserveWhitespace);
                }
            }
        }
 public void OnPairingRequired(ConnectableDevice device, DeviceService service, PairingType pairingType)
 {
 }
 public WebOstvServiceSocketClientListener(DeviceService deviceService, IDeviceServiceListener deviceListener)
 {
     listener = deviceListener;
     service = deviceService;
 }
 public UrlServiceSubscription(DeviceService service, string uri, JsonObject payload,
     ResponseListener listener)
     : base(service, uri, payload, listener)
 {
 }
 public WebAppSession(LaunchSession launchSession, DeviceService service)
 {
     LaunchSession = launchSession;
     Service = service;
 }