Exemplo n.º 1
0
        private Page(Session client, Target target, FrameTree frameTree, bool ignoreHTTPSErrors, TaskQueue screenshotTaskQueue)
        {
            _client           = client;
            _target           = target;
            Keyboard          = new Keyboard(client);
            _mouse            = new Mouse(client, Keyboard);
            Touchscreen       = new Touchscreen(client, Keyboard);
            _frameManager     = new FrameManager(client, frameTree, this);
            _networkManager   = new NetworkManager(client, _frameManager);
            _emulationManager = new EmulationManager(client);
            Tracing           = new Tracing(client);
            _pageBindings     = new Dictionary <string, Func <object> >();

            _ignoreHTTPSErrors = ignoreHTTPSErrors;

            _screenshotTaskQueue = screenshotTaskQueue;

            //TODO: Do we need this bubble?
            _frameManager.FrameAttached  += (sender, e) => FrameAttached?.Invoke(this, e);
            _frameManager.FrameDetached  += (sender, e) => FrameDetached?.Invoke(this, e);
            _frameManager.FrameNavigated += (sender, e) => FrameNavigated?.Invoke(this, e);

            _networkManager.RequestCreated  += (sender, e) => RequestCreated?.Invoke(this, e);
            _networkManager.RequestFailed   += (sender, e) => RequestFailed?.Invoke(this, e);
            _networkManager.ResponseCreated += (sender, e) => ResponseCreated?.Invoke(this, e);
            _networkManager.RequestFinished += (sender, e) => RequestFinished?.Invoke(this, e);

            _client.MessageReceived += client_MessageReceived;
        }
Exemplo n.º 2
0
            public async Task <CreateRequestResponse> CreateRequest(Request request)
            {
                var createdBy = new SqlParameter("@CreatedBy", request.CreatedBy);
                var title     = new SqlParameter("@Title", request.Title);
                var fromDate  = new SqlParameter("@FromDate", request.StartDate);
                var toDate    = new SqlParameter("@ToDate", request.EndDate);

                toDate.Value = (object)request.EndDate ?? DBNull.Value;
                var server      = new SqlParameter("@Server", request.ServerId);
                var description = new SqlParameter("@Description", request.Description);

                var command = _context.Database.GetDbConnection().CreateCommand();

                command.CommandText = "CreateRequest";
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.Add(createdBy);
                command.Parameters.Add(title);
                command.Parameters.Add(fromDate);
                command.Parameters.Add(toDate);
                command.Parameters.Add(server);
                command.Parameters.Add(description);

                var success = await _context.SaveChangesAsync();

                if (success == 0)
                {
                }
                if (command.Connection.State == ConnectionState.Closed)
                {
                    await command.Connection.OpenAsync();
                }
                try
                {
                    var requestReader = await command.ExecuteReaderAsync();

                    await requestReader.ReadAsync();

                    var requestCreatedEvent = new RequestCreated()
                    {
                        RequesterId       = (Guid)requestReader["RequesterId"],
                        CreatedAt         = Convert.ToDateTime(requestReader["CreatedAt"]),
                        RequesterFullName = Convert.ToString(requestReader["RequesterFullName"]),
                        RequesterUsername = Convert.ToString(requestReader["RequesterUsername"]),
                        RequestId         = (Guid)requestReader["RequestId"],
                        ServerId          = (Guid)requestReader["ServerId"],
                        ServerName        = (string)requestReader["ServerName"],
                    };

                    await _eventBus.Trigger(requestCreatedEvent);

                    return(new CreateRequestResponse(requestCreatedEvent.RequestId, true));
                }
                catch (Exception e)
                {
                    // Unique constraint violation code number
                    Console.Error.WriteLine(e);
                    return(new CreateRequestResponse(Guid.Empty, false, new[]
                                                     { new Error(Error.Codes.UNKNOWN, Error.Messages.UNKNOWN) }));
                }
            }
Exemplo n.º 3
0
        public async Task <UtoRequest> CreateRequest(Employee employee, DateTime day, uint hours)
        {
            var request = new UtoRequest(++_maxId, employee, day, hours);
            var created = new RequestCreated(request);

            await _getStore().WriteEvent(created, Streams.UtoRequests);

            return(request);
        }
Exemplo n.º 4
0
 public virtual void OnRequestCreated(WebEventArgs e)
 {
     RequestCreated?.Invoke(this, e);
 }