Пример #1
0
 protected BaseController(ILogService LogService = null, IMapper mapper = null, IHubContext <ChartHub> chartHubContext = null, IRoomService roomService = null, IDeviceService deviceService = null, ICommunicationUnitService communicationUnitService = null)
 {
     _mapper                   = mapper;
     _LogService               = LogService;
     _chartHubContext          = chartHubContext;
     _roomService              = roomService;
     _deviceService            = deviceService;
     _communicationUnitService = communicationUnitService;
     _hub = new ChartHub(_roomService, _mapper, _chartHubContext, deviceService);
 }
Пример #2
0
        public IActionResult Login([FromBody] Client user)
        {
            Client client = _db.FindClient(user.Mobile, user.Password);

            if (client == null)
            {
                // return BadRequest("Invalid client request");
                User userr = _db.FindUser(user.Mobile, user.Password);
                if (userr == null)
                {
                    return(BadRequest("Invalid client request"));
                }
                else
                {
                    string rolename = userr.Role.Role1;
                    int    UserId   = userr.Id;
                    var    claims   = new[]
                    { new Claim("UserId", UserId.ToString()),
                      new Claim("role", rolename),
                      new Claim(JwtRegisteredClaimNames.Jti, Guid.NewGuid().ToString()), };
                    var secretKey         = new SymmetricSecurityKey(Encoding.UTF8.GetBytes("superSecretKey@345"));
                    var signinCredentials = new SigningCredentials(secretKey, SecurityAlgorithms.HmacSha256);

                    var tokeOptions = new JwtSecurityToken(
                        issuer: "http://*****:*****@345"));
                var signinCredentials = new SigningCredentials(secretKey, SecurityAlgorithms.HmacSha256);

                var tokeOptions = new JwtSecurityToken(
                    issuer: "http://localhost:50856",
                    audience: "http://localhost:50856",
                    claims: claims,
                    expires: DateTime.Now.AddMinutes(5),
                    signingCredentials: signinCredentials
                    );

                var tokenString = new JwtSecurityTokenHandler().WriteToken(tokeOptions);
                return(Ok(new { Token = tokenString }));
            }
            //else
            //{
            //    return Unauthorized();
            //}
        }
Пример #3
0
 public void OnHistorianDataChanged(HistorianValue[] historianValues)
 {
     ChartHub.HistorianDataChanged(historianValues);
 }
Пример #4
0
 public void OnPdgtmDataChanged(PdgtmValue[] pdgtmValues)
 {
     ChartHub.PdgtmDataChanged(pdgtmValues);
 }