public AccountSignResult CreateNew(ClientDevice entity)
        {
            var result = new AccountSignResult();

            result.SignStatus = SignStatus.None;

            if (null == entity ||
                string.IsNullOrEmpty(entity.DeviceKey) ||
                string.IsNullOrEmpty(entity.Product) ||
                string.IsNullOrEmpty(entity.Brand))
            {
                this.ReturnPreconditionFailedMessage();
            }

            var account = AccountAuthentication.CreateNew(entity);

            if (null != account)
            {
                result.SignStatus = SignStatus.Success;
                result.Account    = new AccountEntity(account, null);

                WriteTokenToBrowser(result);
            }
            else
            {
                result.SignStatus = SignStatus.Error;
            }

            return(result);
        }
Exemple #2
0
        //SynSendRequest
        private void button7_Click(object sender, EventArgs e)
        {
            ParamPackage packageSended = PackMessage();
            ClientDevice targetClient  = null;

            foreach (ClientDevice item in clientDeviceList)
            {
                if (item.Detail == comboBox12.SelectedItem.ToString())
                {
                    targetClient = item;
                }
            }
            string commuicateName = this.comboBox9.SelectedItem.ToString();
            RequestCommunicatePackage requestCommunicatePackage = localDevice.CreateRequestCommunicatePackage(commuicateName, (CommunicatType)comboBox11.SelectedItem, packageSended, targetClient, checkBox1.Checked, asynReponseHandler);

            try
            {
                localDevice.SynSendRequest(requestCommunicatePackage, int.Parse(this.textBox4.Text));
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
            ReplyPackage replyPkg = requestCommunicatePackage.ResponsePackage;

            if (null != replyPkg)
            {
                //List<string> list = replyPkg.Values<string>("value");
                string replyString = replyPkg.ReplyState.ToString();
                Console.WriteLine(replyString.ToString());
            }
        }
Exemple #3
0
        public void Initialize(IClientDeviceConnection brokerConnection)
        {
            // Creating a air conditioner device.
            _clientDevice = DeviceFactory.CreateClientDevice("air-conditioner");

            // Creating properties.
            _turnOnOfProperty = _clientDevice.CreateClientChoiceProperty(new ClientPropertyMetadata {
                PropertyType = PropertyType.Command, NodeId = "general", PropertyId = "turn-on-off", Format = "ON,OFF"
            });
            _actualState = _clientDevice.CreateClientChoiceProperty(new ClientPropertyMetadata {
                PropertyType = PropertyType.State, NodeId = "general", PropertyId = "actual-state", Format = "ON,OFF,STARTING", InitialValue = "OFF"
            });
            _actualState.PropertyChanged += (sender, e) => {
                _log.Info($"{_clientDevice.DeviceId}: property {_actualState.PropertyId} changed to {_actualState.Value}.");
            };

            _inletTemperature = _clientDevice.CreateClientNumberProperty(new ClientPropertyMetadata {
                PropertyType = PropertyType.State, NodeId = "general", PropertyId = "actual-air-temperature", DataType = DataType.Float, InitialValue = "0"
            });
            _inletTemperature.PropertyChanged += (sender, e) => {
                // Simulating some overheated dude.
                if (_inletTemperature.Value > 25)
                {
                    _log.Info($"{_clientDevice.Name}: getting hot in here, huh?.. Let's try turning air conditioner on.");
                    if (_actualState.Value != "ON")
                    {
                        _turnOnOfProperty.Value = "ON";
                    }
                }
            };

            // Initializing all the Homie stuff.
            _clientDevice.Initialize(brokerConnection);
        }
Exemple #4
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public static AccountEntity CreateNew()
        {
            var accountInfo = new ClientDevice()
            {
                DeviceKey = Guid.NewGuid().ToString("N"),
                Brand     = "test:Brand",
                Device    = "test:Device",
                Product   = "test:Product"
            };
            var responseResult = WebApiClient.HttpPost(ApiEnvironment.Account_CreateNew_Endpoint, accountInfo);

            if (responseResult.StatusCode != HttpStatusCode.OK)
            {
                Console.WriteLine(responseResult.StatusCode);
                Console.WriteLine(responseResult.Content);
            }

            var entity = responseResult.Content.ConvertEntity <AccountSignResult>();

            Assert.IsNotNull(entity);
            Assert.AreEqual(SignStatus.Success, entity.SignStatus);
            Assert.IsNotNull(entity.Account);
            Assert.IsNotNull(entity.Account.Token);
            Assert.IsNotNull(entity.Account.Token.AccessToken);

            WebApiClient.SaveAuthToken(entity.Account.Token.AccessToken);
            Console.WriteLine("NewAccount:\t{0}\r\n", responseResult.Content);
            return(entity.Account);
        }
Exemple #5
0
        public ActionResult DeleteConfirmed(int id)
        {
            ClientDevice clientDevice = db.ClientDevices.Find(id);

            db.ClientDevices.Remove(clientDevice);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemple #6
0
 public ReplyMTPackage(C2CReplyPackage c2cReplyPackage,
                       ClientDevice sourceDevice,
                       ClientDevice tagetDevice,
                       string replyId)
     : base(c2cReplyPackage, sourceDevice, tagetDevice)
 {
     this.RepliedMessageId = replyId;
 }
Exemple #7
0
 public MiddlewareTransferPackage(ParamPackage c2cMessagePackage,
                                  ClientDevice sourceDevice,
                                  ClientDevice targetDevice)
 {
     _c2cMessagePackage = c2cMessagePackage;
     _sourceDevice      = sourceDevice;
     _targetDevice      = targetDevice;
 }
 public C2CRequestPackage(ClientDevice sourDevice,
                          string oprName,
                          bool waittingResp,
                          Dictionary <string, byte[]> _attrDefaultValues)
     : base(sourDevice, oprName, waittingResp,
            _attrDefaultValues)
 {
 }
Exemple #9
0
 public RequestMTPackage(C2CRequestPackage c2cNormalTransPackage,
                         ClientDevice sourceDevice,
                         ClientDevice targetDevice,
                         bool waittingResponse)
     : base(c2cNormalTransPackage, sourceDevice, targetDevice)
 {
     _bWaittingResponse = waittingResponse;
 }
Exemple #10
0
 public ActionResult Edit([Bind(Include = "ClientDeviceId,ClientId,DeviceList")] ClientDevice clientDevice)
 {
     if (ModelState.IsValid)
     {
         db.Entry(clientDevice).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(clientDevice));
 }
 public RequestPackage(ClientDevice sourDevice,
                       string communicationName,
                       bool waitResponse,
                       Dictionary <string, byte[]> _attrDefaultValues)
     : base("RequestTransferPackage",
            _attrDefaultValues)
 {
     _communicationName = communicationName;
     _sourDevice        = sourDevice;
     _waitResponse      = waitResponse;
 }
Exemple #12
0
        public ActionResult Create([Bind(Include = "ClientDeviceId,ClientId,DeviceList")] ClientDevice clientDevice)
        {
            if (ModelState.IsValid)
            {
                db.ClientDevices.Add(clientDevice);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(clientDevice));
        }
        public bool RegisterClient(ClientDevice clientDevice, string connectionId)
        {
            var connectedClient = new ConnectedClient
            {
                ConnectionId = connectionId,
                ConnectedOn  = DateTime.UtcNow,
                Client       = clientDevice
            };

            return(Connections.TryAdd(connectionId, connectedClient));
        }
        public bool Start()
        {
            ClientDevice.Start();
            HostDevice.Start();
            Sync();

            var result = ClientDevice.IsOperational;

            CurrentStatus.IsOperational = result;
            return(result);
        }
 public bool ClientConnected(ClientDevice client, string connectionId)
 {
     using (var dbContext = new SchedulerContext())
     {
         if (!dbContext.Clients.Any(c => c.Name == client.Name))
         {
             dbContext.Clients.Add(client);
             dbContext.SaveChanges();
             Context.Value.Clients.All.clientAdded(client);
         }
         return(ClientsRegistry.Value.RegisterClient(client, connectionId));
     }
 }
 private static ClientDevice GetAvailableClientDevice()
 {
     clientDeviceInstance = null;
     lock (objLock)
     {
         while (clientDeviceInstance == null)
         {
             clientDeviceInstance = clientDevices.Where(clientdevice => clientdevice.IsClientReady == true).FirstOrDefault();
             System.Threading.Thread.Sleep(1000);
         }
         clientDeviceInstance.IsClientReady = false;
         return clientDeviceInstance;
     }
 }
Exemple #17
0
        // GET: ClientDevices/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ClientDevice clientDevice = db.ClientDevices.Find(id);

            if (clientDevice == null)
            {
                return(HttpNotFound());
            }
            return(View(clientDevice));
        }
        public static AnonymousAccount CreateNew(ClientDevice device)
        {
            if (null == device)
            {
                return(null);
            }

            device.DeviceId     = 0;
            device.CreatedTime  = DateTime.Now;
            device.ModifiedTime = device.CreatedTime;
            device.Save();

            var account = AnonymousAccount.CreateNew(device.DeviceId);

            return(account);
        }
        protected void CoNewClientInitialization(MiddlewareTcpEndPoint endPoint, string detail, List <string> oprRules, List <string> opredRules)
        {
            string token = null;

            _binProcessferProcessor.Initialization(endPoint);
            token = __FirstHandShake(detail);

            _middlewareCommunicateProcessor.Initialization();
            _groupCommunicateProcessor.Initialization();

            _binProcessferProcessor.Connected    += __BinLayerConnectedHandler;
            _binProcessferProcessor.Disconnected += __BinLayerDisConnectedHandler;

            _selfDevice          = new ClientDevice(token, detail);
            _bFirstLinkSucessful = true;
            _bIsOnline           = true;
        }
        protected RequestCommunicatePackage CoCreateRequestCommunicatePackage(string communicationName,
                                                                              CommunicatType communicateType,
                                                                              ParamPackage reqtParamPkg,
                                                                              ClientDevice targetDevice,
                                                                              bool waitResponse,
                                                                              AsynReponseHandler callback)
        {
            RequestCommunicatePackage reqtPkg = new RequestCommunicatePackage();

            reqtPkg.CommunicationName       = communicationName;
            reqtPkg.CommunicateType         = communicateType;
            reqtPkg.ParamPackage            = reqtParamPkg;
            reqtPkg.TargetDevice            = targetDevice;
            reqtPkg.WaitResponse            = waitResponse;
            reqtPkg.AsynchronousReponseCame = callback;
            return(reqtPkg);
        }
Exemple #21
0
        //AsynSendRequest
        private void button6_Click(object sender, EventArgs e)
        {
            ParamPackage packageSended = PackMessage();
            ClientDevice targetClient  = null;

            foreach (ClientDevice item in clientDeviceList)
            {
                if (item.Detail == comboBox12.SelectedItem.ToString())
                {
                    targetClient = item;
                }
            }
            string radioOp        = this.comboBox8.SelectedItem.ToString();
            string commuicateName = this.comboBox9.SelectedItem.ToString();
            RequestCommunicatePackage requestCommunicatePackage = localDevice.CreateRequestCommunicatePackage(commuicateName, (CommunicatType)comboBox11.SelectedItem, packageSended, targetClient, checkBox1.Checked, asynReponseHandler);

            localDevice.AsynSendRequest(requestCommunicatePackage);
        }
Exemple #22
0
        public void Initialize(IClientDeviceConnection brokerConnection, ClientDeviceMetadata deviceMetadata)
        {
            _clientDevice = DeviceFactory.CreateClientDevice(deviceMetadata);

            for (var i = 0; i < _clientDevice.Nodes.Length; i++)
            {
                Debug.Print($"Iterating over nodes. Currently: \"{_clientDevice.Nodes[i].Name}\" with {_clientDevice.Nodes[i].Properties.Length} properties.");

                foreach (var property in _clientDevice.Nodes[i].Properties)
                {
                    property.PropertyChanged += (sender, e) => {
                        Debug.WriteLine($"Value of property \"{property.Name}\" changed to \"{property.RawValue}\".");
                    };
                }
            }

            // Initializing all the Homie stuff.
            _clientDevice.Initialize(brokerConnection);
        }
        static void InitClient()
        {
            var accessToken = CookieHelper.GetValue(AccountAuthentication.TokenKey);

            if (null == accessToken)
            {
                var clientDevice = new ClientDevice()
                {
                    DeviceKey = "0000",
                    Product   = "JUXIAN",
                    Brand     = "JUXIAN"
                };

                var signResult = new AccountController().CreateNew(clientDevice);
                if (null != signResult)
                {
                    CookieHelper.SetCookie(AccountAuthentication.TokenKey, signResult.Account.Token.AccessToken);
                }
            }
        }
        public void Initialize(IClientDeviceConnection _brokerConnection)
        {
            // Creating a air conditioner device.
            _clientDevice = DeviceFactory.CreateClientDevice("lightbulb");

            // Creating properties.
            _color = _clientDevice.CreateClientColorProperty(new ClientPropertyMetadata {
                PropertyType = PropertyType.Parameter, NodeId = "general", PropertyId = "color", Format = "rgb", InitialValue = "0,0,0"
            });
            _color.PropertyChanged += (sender, e) => {
                if (_color.Value.RedValue > 0)
                {
                    Console.WriteLine("Me no like red!");
                    _color.Value = HomieColor.FromRgbString("0,128,128");
                }
            };

            // Initializing all the Homie stuff.
            _clientDevice.Initialize(_brokerConnection);
        }
        protected void CoOldClientInitialization(MiddlewareTcpEndPoint endPoint, string detail, string token, List <string> oprRules, List <string> opredRules)
        {
            _binProcessferProcessor.Initialization(endPoint);
            try
            {
                __Relink(token);
            }
            catch (System.Exception ex)
            {
                throw new InitializationExtion(ex.ToString());
            }
            _middlewareCommunicateProcessor.Initialization();
            _groupCommunicateProcessor.Initialization();

            _binProcessferProcessor.Connected    += __BinLayerConnectedHandler;
            _binProcessferProcessor.Disconnected += __BinLayerDisConnectedHandler;

            _selfDevice          = new ClientDevice(token, detail);
            _bFirstLinkSucessful = true;
            _bIsOnline           = true;
        }
Exemple #26
0
        public ActionResult LoadAccountInfo()
        {
            AccountEntity accountEntity = null;

            if (null != this.Request.UserAgent && null != this.Request.UrlReferrer)
            {
                var accessToken = CookieHelper.GetValue(AccountAuthentication.TokenKey);
                if (null == accessToken)
                {
                    var device = new ClientDevice();
                    accountEntity = new AccountEntity(AccountAuthentication.CreateNew(device), null);;

                    CookieHelper.SetCookie(AccountAuthentication.TokenKey, accountEntity.Token.AccessToken, DateTime.MaxValue);
                }
                else
                {
                    accountEntity = new AccountEntity(MvcContext.Current.ClientAccount, MvcContext.Current.UserPassport);
                }
            }

            return(View("LoadAccountJS", accountEntity));
        }
 public AutomationAgent(string testDetails, bool launchApp = true)
 {
     if (ConfigurationManager.AppSettings["IsParallelTestExecution"].ToString() == "true")
     {
         this.clientDevice = ClientDeviceFactory.AvailableClientDevice;
     }
     else
     {
         this.clientDevice = SingletonClientDevice.clientDevice;
         clientDevice.IsClientReady = false;
     }
     this.client = this.clientDevice.Client;
     this.device = this.clientDevice.Device;
     this.testDetails = testDetails;
     this.appName = ConfigurationManager.AppSettings["AppName"].ToString();
     this.launchingAppName = ConfigurationManager.AppSettings["DevLaunchingAppName"].ToString();
     this.osName = ConfigurationManager.AppSettings["OS"].ToString();
     string startupPath = System.IO.Directory.GetCurrentDirectory();
     string outPutDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().CodeBase);
     this.projectBaseDirectory = new Uri(outPutDirectory + "\\" + ConfigurationManager.AppSettings["ProjectBaseDirectory"].ToString()).LocalPath;
     this.SetShowPassImageInReport = bool.Parse(ConfigurationManager.AppSettings["SetShowPassImageInReport"]);
     InitializeClientAndLaunchApp(launchApp);
 }
 public void Shutdown()
 {
     ClientDevice.Stop();
     HostDevice.Stop();
     CurrentStatus.IsOperational = false;
 }
 protected void CoListen(ClientDevice messenger, BaseMessageType typMsg)
 {
     mMiddlewareMessenger.Listen(messenger, typMsg);
 }
 public void Initialize(string mqttBrokerIpAddress, ClientDeviceMetadata clientDeviceMetadata)
 {
     ClientDevice = DeviceFactory.CreateClientDevice(clientDeviceMetadata);
     _broker.Initialize(mqttBrokerIpAddress);
     ClientDevice.Initialize(_broker, (severity, message) => { Console.WriteLine($"{severity}:{message}"); });
 }
Exemple #31
0
 public void ClientAdded(ClientDevice client)
 {
     Clients.All.clientAdded(client);
 }
        void TestClientPlatform(UnrealTargetPlatform Platform)
        {
            string GameName  = this.ProjectFile.FullName;
            string BuildPath = this.BuildPath;
            string DevKit    = this.DevkitName;

            if (GameName.Equals("OrionGame", StringComparison.OrdinalIgnoreCase) == false)
            {
                Log.Info("Skipping test {0} due to non-Orion project!", this);
                MarkComplete();
                return;
            }

            // create a new build
            UnrealBuildSource Build = new UnrealBuildSource(ProjectFile, this.UnrealPath, UsesSharedBuildType, BuildPath);

            // check it's valid
            if (!CheckResult(Build.BuildCount > 0, "staged build was invalid"))
            {
                MarkComplete();
                return;
            }

            // Create devices to run the client and server
            ITargetDevice ServerDevice = new TargetDeviceWindows("PC Server", Gauntlet.Globals.TempDir);
            ITargetDevice ClientDevice = null;

            if (Platform == UnrealTargetPlatform.PS4)
            {
                //ClientDevice = new TargetDevicePS4(this.PS4Name);
            }
            else
            {
                ClientDevice = new TargetDeviceWindows("PC Client", Gauntlet.Globals.TempDir);
            }

            UnrealAppConfig ServerConfig = Build.CreateConfiguration(new UnrealSessionRole(UnrealTargetRole.Server, ServerDevice.Platform, UnrealTargetConfiguration.Development));
            UnrealAppConfig ClientConfig = Build.CreateConfiguration(new UnrealSessionRole(UnrealTargetRole.Client, ClientDevice.Platform, UnrealTargetConfiguration.Development));

            if (!CheckResult(ServerConfig != null && ServerConfig != null, "Could not create configs!"))
            {
                MarkComplete();
                return;
            }

            ShortSoloOptions Options = new ShortSoloOptions();

            Options.ApplyToConfig(ClientConfig);
            Options.ApplyToConfig(ServerConfig);

            IAppInstall ClientInstall = ClientDevice.InstallApplication(ClientConfig);
            IAppInstall ServerInstall = ServerDevice.InstallApplication(ServerConfig);

            if (!CheckResult(ServerConfig != null && ServerConfig != null, "Could not create configs!"))
            {
                MarkComplete();
                return;
            }

            IAppInstance ClientInstance = ClientInstall.Run();
            IAppInstance ServerInstance = ServerInstall.Run();

            DateTime StartTime        = DateTime.Now;
            bool     RunWasSuccessful = true;

            while (ClientInstance.HasExited == false)
            {
                if ((DateTime.Now - StartTime).TotalSeconds > 800)
                {
                    RunWasSuccessful = false;
                    break;
                }
            }

            ClientInstance.Kill();
            ServerInstance.Kill();

            UnrealLogParser LogParser = new UnrealLogParser(ClientInstance.StdOut);

            UnrealLogParser.CallstackMessage ErrorInfo = LogParser.GetFatalError();
            if (ErrorInfo != null)
            {
                CheckResult(false, "FatalError - {0}", ErrorInfo.Message);
            }

            RunWasSuccessful = LogParser.HasRequestExit();

            CheckResult(RunWasSuccessful, "Failed to run for platform {0}", Platform);
        }