Esempio n. 1
0
        private async Task <GetReportResultContextCollection> GetInformation(IncidentWrapper incident)
        {
            var report =
                await incident.GetReport(x => x.ContextCollections.Any(y => y.Name == "UserSuppliedInformation"));

            return(report.ContextCollections.FirstOrDefault(x => x.Name == "UserSuppliedInformation"));
        }
Esempio n. 2
0
        public async Task <IncidentWrapper> CreateIncident(object contextData, Action <ErrorReportDTO> callback = null)
        {
            var wrapper = new IncidentWrapper(_apiClient, _reporter, ApplicationId);
            await wrapper.Create(contextData, callback);

            return(wrapper);
        }
Esempio n. 3
0
        public async Task <IncidentWrapper> CreateIncidentWithoutSignature(Action <ErrorReportDTO> callback = null)
        {
            var wrapper = new IncidentWrapper(_apiClient, _reporter, ApplicationId);
            await wrapper.CreateWithoutSignature(callback);

            return(wrapper);
        }
Esempio n. 4
0
    public static void Test()
    {
        string      baseAddress = "http://" + Environment.MachineName + ":8000/Service";
        ServiceHost host        = new ServiceHost(typeof(Service), new Uri(baseAddress));
        var         endpoint    = host.AddServiceEndpoint(typeof(IGetActiveIncidents), new WebHttpBinding(), "");

        endpoint.Behaviors.Add(new WebScriptEnablingBehavior());
        host.Open();
        Console.WriteLine("Host opened");
        //Using a "normal" HTTP client
        WebClient c = new WebClient();

        byte[]       data = c.DownloadData(baseAddress + "/GetActiveIncidents?environmentAbbreviation=dd");
        MemoryStream ms   = new MemoryStream(data);
        DataContractJsonSerializer dcjs    = new DataContractJsonSerializer(typeof(IncidentWrapper));
        IncidentWrapper            wrapper = (IncidentWrapper)dcjs.ReadObject(ms);

        Console.WriteLine("Using HttpClient/DCJS: {0}", wrapper.Incidents.Count);
        // Using a WCF client (with WebScriptEnablingBehavior
        ChannelFactory <IGetActiveIncidents> factory = new ChannelFactory <IGetActiveIncidents>(new WebHttpBinding(), new EndpointAddress(baseAddress));

        factory.Endpoint.Behaviors.Add(new WebScriptEnablingBehavior());
        IGetActiveIncidents proxy = factory.CreateChannel();

        Console.WriteLine("Using WCF client (with WSEB): {0}", proxy.GetActiveIncidents("dd").Count);
    }
        public async Task Should_not_add_report_when_being_blocked()
        {
            var cmd = new AddEntry
            {
                DomainName     = "report4.coderr.io",
                ApplicationIds = new[] { 1 },
                IpAddresses    = new[] { "1.2.3.4" }
            };
            await _apiClient.SendAsync(cmd);

            await GetEntry(x => x.DomainName == cmd.DomainName);

            IncidentWrapper entry = null;

            try
            {
                entry = await _applicationClient.CreateIncidentWithoutSignature();
            }
            catch
            {
                // should throw since the report should be ignored.
            }

            entry.Should().BeNull();
        }
Esempio n. 6
0
        /// <summary>
        /// Function to send student email about their next scheduled exam.
        /// </summary>
        /// <param name="wrapper"></param>
        /// <param name="context"></param>
        /// <returns></returns>
        public void FunctionHandler(IncidentWrapper wrapper, ILambdaContext context)
        {
            var nextExam   = wrapper.Input.Exams.FirstOrDefault();
            var studentId  = wrapper.Input.StudentId;
            var token      = wrapper.TaskToken;
            var incidentId = wrapper.Input.IncidentId.ToString("D");
            var examCount  = wrapper.Input.Exams.Count;

            if (nextExam != null)
            {
                SendEmail(nextExam, studentId, token, incidentId, examCount).Wait();
                context.Logger.Log("Done");
            }
            else
            {
                throw new ExamNotFoundException();
            }
        }
        public FunctionTests()
        {
            _context = new TestLambdaContext();

            _incidentIn = new IncidentWrapper()
            {
                Input = new Incident
                {
                    IncidentId   = Guid.NewGuid(),
                    StudentId    = "123",
                    IncidentDate = new DateTime(2018, 02, 03),
                    Exams        = new List <Exam>()
                    {
                        new Exam(Guid.NewGuid(), new DateTime(2018, 02, 17), 0),
                        new Exam(Guid.NewGuid(), new DateTime(2018, 02, 10), 65)
                    },
                    ResolutionDate = null
                },
                TaskToken = "TASKTOKEN"
            };
        }
Esempio n. 8
0
        /// <summary>Metoda asynchronicznie ładująca dane o wydarzeniu. Jeśli dane wydarzenie nie istnieje, to zostaje utworzone. Jeśli w wydarzeniu zaszły zmiany to są one obsługiwane.</summary>
        /// <param name="incidentId">Identyfikator wydarzenia, który może być NULL.</param>
        public async Task LoadAsync(int?incidentId)
        {
            var incident = incidentId.HasValue
                ? await _incidentRepository.GetByIdAsync(incidentId.Value)
                : CreateNewIncident();

            Incident = new IncidentWrapper(incident);
            Incident.PropertyChanged += (s, e) =>
            {
                if (!HasChanges)
                {
                    HasChanges = _incidentRepository.HasChanges();
                }
                if (e.PropertyName == nameof(Incident.HasErrors))
                {
                    ((DelegateCommand)SaveCommand).RaiseCanExecuteChanged();
                }
            };
            ((DelegateCommand)SaveCommand).RaiseCanExecuteChanged();
            if (Incident.Id == 0)
            {
                Incident.Title = "";
            }
        }